diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/assets/javascripts/authentication/u2f/error.js | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/assets/javascripts/authentication/u2f/error.js')
-rw-r--r-- | app/assets/javascripts/authentication/u2f/error.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/assets/javascripts/authentication/u2f/error.js b/app/assets/javascripts/authentication/u2f/error.js new file mode 100644 index 00000000000..ca0fc0700ad --- /dev/null +++ b/app/assets/javascripts/authentication/u2f/error.js @@ -0,0 +1,26 @@ +import { __ } from '~/locale'; + +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; + } + + message() { + if (this.errorCode === window.u2f.ErrorCodes.BAD_REQUEST && this.httpsDisabled) { + return __( + 'U2F only works with HTTPS-enabled websites. Contact your administrator for more details.', + ); + } else if (this.errorCode === window.u2f.ErrorCodes.DEVICE_INELIGIBLE) { + if (this.u2fFlowType === 'authenticate') { + return __('This device has not been registered with us.'); + } + if (this.u2fFlowType === 'register') { + return __('This device has already been registered with us.'); + } + } + return __('There was a problem communicating with your device.'); + } +} |