silverstripe / silverstripe-webauthn-authenticator

@@ -13,6 +13,7 @@
Loading
13 13
export const VIEWS = {
14 14
  LOADING: 'LOADING', // Preparing to render the form
15 15
  READY: 'READY', // Waiting for the user to start the process
16 +
  ERROR: 'ERROR', // Something went wrong while loading or processing
16 17
  REGISTERING: 'REGISTERING', // Waiting for the security key / server
17 18
  FAILURE: 'FAILURE', // Timeout or other error from registration
18 19
  SUCCESS: 'SUCCESS', // Successful registration
@@ -26,8 +27,15 @@
Loading
26 27
  constructor(props) {
27 28
    super(props);
28 29
30 +
    let view = VIEWS.LOADING;
31 +
    if (props.keyData) {
32 +
      view = VIEWS.READY;
33 +
    } else if (props.errors.length) {
34 +
      view = VIEWS.ERROR;
35 +
    }
36 +
29 37
    this.state = {
30 -
      view: props.keyData ? VIEWS.READY : VIEWS.LOADING,
38 +
      view,
31 39
      registrationData: null,
32 40
    };
33 41
@@ -129,6 +137,7 @@
Loading
129 137
   * @returns {HTMLElement}
130 138
   */
131 139
  renderStatus() {
140 +
    const { errors } = this.props;
132 141
    const { ss: { i18n } } = window;
133 142
134 143
    switch (this.state.view) {
@@ -163,6 +172,15 @@
Loading
163 172
            </span>
164 173
          </div>
165 174
        );
175 +
      case VIEWS.ERROR:
176 +
        return (
177 +
          <div className="mfa-registration-container__status status-message--error">
178 +
            <span className="status-message__icon"><CircleWarning size="32px" /></span>
179 +
            <span className="status-message__description">
180 +
              {errors.join(', ')}
181 +
            </span>
182 +
          </div>
183 +
        );
166 184
    }
167 185
  }
168 186
@@ -207,6 +225,10 @@
Loading
207 225
          },
208 226
        ];
209 227
        break;
228 +
      case VIEWS.ERROR:
229 +
        // Deliberately do not provide any actions for backend errors, a refresh is required
230 +
        actions = [];
231 +
        break;
210 232
      case VIEWS.READY:
211 233
        actions = [
212 234
          {
@@ -299,13 +321,16 @@
Loading
299 321
  }
300 322
}
301 323
302 -
303 324
Register.propTypes = {
304 325
  keyData: PropTypes.object,
305 326
  method: PropTypes.object.isRequired,
327 +
  errors: PropTypes.arrayOf(PropTypes.string),
306 328
  onBack: PropTypes.func.isRequired,
307 329
  onCompleteRegistration: PropTypes.func.isRequired,
308 -
  // uri: PropTypes.string.isRequired,
330 +
};
331 +
332 +
Register.defaultProps = {
333 +
  errors: [],
309 334
};
310 335
311 336
Register.displayName = 'WebAuthnRegister';
Files Complexity Coverage
client/src 0 33.80%
src 50 35.47%
Project Totals (13 files) 50 34.71%
50.2
TRAVIS_NODE_VERSION=10
TRAVIS_OS_NAME=linux
js
50.3
TRAVIS_NODE_VERSION=10
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading