silverstripe / silverstripe-webauthn-authenticator

Compare c4f81f2 ... +2 ... 4282cd4

Flags

Flags have been temporarily removed from this view while the flagging feature is refactored for better performance and user experience.

You can still use flags when viewing individual files. Flag-level thresholds will also remain on pull and merge requests in your repository provider.

More information can be found in our documentation.


@@ -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';

Learn more Showing 6 files with coverage changes found.

Changes in client/src/components/Icons/CircleTick.js
-1
+1
Loading file...
Changes in client/src/components/LoadingIndicator.js
-1
Loading file...
Changes in client/src/components/Icons/CircleWarning.js
-1
+1
Loading file...
Changes in client/src/lib/auth.js
-2
+1
Loading file...
Changes in client/src/components/WebAuthn/Register.js
-22
+21
Loading file...
Changes in client/src/lib/convert.js
-1
+2
Loading file...
Files Complexity Coverage
components ø +33.61% 33.61%
lib ø +20.00% 20.00%
state/webauthnAvailableReducer.js ø 100.00%
types/publicKey.js ø 0.00%
Folder Totals (4 files) 0 33.80%
Project Totals (14 files) 54 44.24%
Loading