debian-mirror-gitlab/app/assets/javascripts/authentication/u2f/error.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
918 B
JavaScript
Raw Normal View History

2019-07-31 22:56:46 +05:30
import { __ } from '~/locale';
2018-03-17 18:26:18 +05:30
export default class U2FError {
constructor(errorCode, u2fFlowType) {
this.errorCode = errorCode;
this.message = this.message.bind(this);
this.httpsDisabled = window.location.protocol !== 'https:';
this.u2fFlowType = u2fFlowType;
}
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
message() {
if (this.errorCode === window.u2f.ErrorCodes.BAD_REQUEST && this.httpsDisabled) {
2019-07-31 22:56:46 +05:30
return __(
'U2F only works with HTTPS-enabled websites. Contact your administrator for more details.',
);
2018-03-17 18:26:18 +05:30
} else if (this.errorCode === window.u2f.ErrorCodes.DEVICE_INELIGIBLE) {
if (this.u2fFlowType === 'authenticate') {
2019-07-31 22:56:46 +05:30
return __('This device has not been registered with us.');
2016-09-13 17:45:13 +05:30
}
2018-03-17 18:26:18 +05:30
if (this.u2fFlowType === 'register') {
2019-07-31 22:56:46 +05:30
return __('This device has already been registered with us.');
2018-03-17 18:26:18 +05:30
}
}
2019-07-31 22:56:46 +05:30
return __('There was a problem communicating with your device.');
2018-03-17 18:26:18 +05:30
}
}