summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/u2f/error.js
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-01-02 10:25:28 +0000
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-01-04 01:41:21 +0000
commit932bcb4d32ee89922b6e7123a9c18489b36cc6e5 (patch)
tree81dea6105bee9bf872880db90b927c6c8e3dd317 /app/assets/javascripts/u2f/error.js
parent8dc2163ce580f1d71be1cf45e5dfcb2b4763d7bb (diff)
downloadgitlab-ce-932bcb4d32ee89922b6e7123a9c18489b36cc6e5.tar.gz
Added isAuthenticate to differentiate between ineligible messages26066-wrong-messsage-for-unregistered-u2f-device-on-sign-in
Diffstat (limited to 'app/assets/javascripts/u2f/error.js')
-rw-r--r--app/assets/javascripts/u2f/error.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/assets/javascripts/u2f/error.js b/app/assets/javascripts/u2f/error.js
index bb9942a3aa0..50340d9174a 100644
--- a/app/assets/javascripts/u2f/error.js
+++ b/app/assets/javascripts/u2f/error.js
@@ -5,21 +5,21 @@
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.U2FError = (function() {
- function U2FError(errorCode) {
+ function U2FError(errorCode, u2fFlowType) {
this.errorCode = errorCode;
this.message = bind(this.message, this);
this.httpsDisabled = window.location.protocol !== 'https:';
+ this.u2fFlowType = u2fFlowType;
}
U2FError.prototype.message = function() {
- switch (false) {
- case !(this.errorCode === u2f.ErrorCodes.BAD_REQUEST && this.httpsDisabled):
- return "U2F only works with HTTPS-enabled websites. Contact your administrator for more details.";
- case this.errorCode !== u2f.ErrorCodes.DEVICE_INELIGIBLE:
- return "This device has already been registered with us.";
- default:
- return "There was a problem communicating with your device.";
+ if (this.errorCode === u2f.ErrorCodes.BAD_REQUEST && this.httpsDisabled) {
+ return 'U2F only works with HTTPS-enabled websites. Contact your administrator for more details.';
+ } else if (this.errorCode === 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.";
};
return U2FError;