Welcome to mirror list, hosted at ThFree Co, Russian Federation.

error.js « webauthn « authentication « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 40dbecd8bc909525493b3853f12080e8f20516af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { __ } from '~/locale';
import { WEBAUTHN_AUTHENTICATE, WEBAUTHN_REGISTER } from './constants';
import { isHTTPS } from './util';

export default class WebAuthnError {
  constructor(error, flowType) {
    this.error = error;
    this.errorName = error.name || 'UnknownError';
    this.message = this.message.bind(this);
    this.httpsDisabled = !isHTTPS();
    this.flowType = flowType;
  }

  message() {
    if (this.errorName === 'NotSupportedError') {
      return __('Your device is not compatible with GitLab. Please try another device');
    } else if (this.errorName === 'InvalidStateError' && this.flowType === WEBAUTHN_AUTHENTICATE) {
      return __('This device has not been registered with us.');
    } else if (this.errorName === 'InvalidStateError' && this.flowType === WEBAUTHN_REGISTER) {
      return __('This device has already been registered with us.');
    } else if (this.errorName === 'SecurityError' && this.httpsDisabled) {
      return __(
        'WebAuthn only works with HTTPS-enabled websites. Contact your administrator for more details.',
      );
    }

    return __('There was a problem communicating with your device.');
  }
}