128549f10b
- Move the `TwoFactorAuthsController`'s `new` action to `show`, since the page is not used to create a single "two factor auth" anymore. We can have a single 2FA authenticator app, along with any number of U2F devices, in any combination, so the page will be accessed after the first "two factor auth" is created. - Add the `u2f` javascript library, which provides an API to the browser's U2F implementation. - Add tests for the JS components
13 lines
551 B
CoffeeScript
13 lines
551 B
CoffeeScript
class @U2FError
|
|
constructor: (@errorCode) ->
|
|
@httpsDisabled = (window.location.protocol isnt 'https:')
|
|
console.error("U2F Error Code: #{@errorCode}")
|
|
|
|
message: () =>
|
|
switch
|
|
when (@errorCode is u2f.ErrorCodes.BAD_REQUEST and @httpsDisabled)
|
|
"U2F only works with HTTPS-enabled websites. Contact your administrator for more details."
|
|
when @errorCode is u2f.ErrorCodes.DEVICE_INELIGIBLE
|
|
"This device has already been registered with us."
|
|
else
|
|
"There was a problem communicating with your device."
|