summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/u2f/error.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/u2f/error.js')
-rw-r--r--app/assets/javascripts/u2f/error.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/assets/javascripts/u2f/error.js b/app/assets/javascripts/u2f/error.js
new file mode 100644
index 00000000000..bc48c67c4f2
--- /dev/null
+++ b/app/assets/javascripts/u2f/error.js
@@ -0,0 +1,27 @@
+(function() {
+ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+
+ this.U2FError = (function() {
+ function U2FError(errorCode) {
+ this.errorCode = errorCode;
+ this.message = bind(this.message, this);
+ this.httpsDisabled = window.location.protocol !== 'https:';
+ console.error("U2F Error Code: " + this.errorCode);
+ }
+
+ 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.";
+ }
+ };
+
+ return U2FError;
+
+ })();
+
+}).call(this);