diff --git a/src/Web/wwwroot/app/settings/settingsTwoFactorController.js b/src/Web/wwwroot/app/settings/settingsTwoFactorController.js index 44d34564f0..5044ad483d 100644 --- a/src/Web/wwwroot/app/settings/settingsTwoFactorController.js +++ b/src/Web/wwwroot/app/settings/settingsTwoFactorController.js @@ -19,16 +19,7 @@ masterPasswordHash: _masterPasswordHash, provider: 0 /* Only authenticator provider for now. */ }, function (response) { - var key = response.AuthenticatorKey; - $scope.twoFactorModel = { - enabled: response.TwoFactorEnabled, - key: formatString(key), - recovery: formatString(response.TwoFactorRecoveryCode), - qr: 'https://chart.googleapis.com/chart?chs=120x120&chld=L|0&cht=qr&chl=otpauth://totp/' + - _issuer + ':' + encodeURIComponent(_profile.email) + - '%3Fsecret=' + encodeURIComponent(key) + - '%26issuer=' + _issuer - }; + processResponse(response); }).$promise; }; @@ -40,6 +31,19 @@ return s.replace(/(.{4})/g, '$1 ').trim().toUpperCase(); } + function processResponse(response) { + var key = response.AuthenticatorKey; + $scope.twoFactorModel = { + enabled: response.TwoFactorEnabled, + key: formatString(key), + recovery: formatString(response.TwoFactorRecoveryCode), + qr: 'https://chart.googleapis.com/chart?chs=120x120&chld=L|0&cht=qr&chl=otpauth://totp/' + + _issuer + ':' + encodeURIComponent(_profile.email) + + '%3Fsecret=' + encodeURIComponent(key) + + '%26issuer=' + _issuer + }; + } + $scope.update = function (model) { var currentlyEnabled = $scope.twoFactorModel.enabled; if (currentlyEnabled && !confirm('Are you sure you want to disable two-step login?')) { @@ -48,7 +52,7 @@ var request = { enabled: !currentlyEnabled, - token: model.token, + token: model.token.replace(' ', ''), masterPasswordHash: _masterPasswordHash }; @@ -57,14 +61,16 @@ $analytics.eventTrack('Enabled Two-step Login'); toastr.success('Two-step login has been enabled.'); if (_profile.extended) _profile.extended.twoFactorEnabled = true; + processResponse(response); + $('#token').blur(); + model.token = null; } else { $analytics.eventTrack('Disabled Two-step Login'); toastr.success('Two-step login has been disabled.'); if (_profile.extended) _profile.extended.twoFactorEnabled = false; + $scope.close(); } - - $scope.close(); }).$promise; }; diff --git a/src/Web/wwwroot/app/settings/views/settingsTwoFactor.html b/src/Web/wwwroot/app/settings/views/settingsTwoFactor.html index c6387c60c1..794c45a782 100644 --- a/src/Web/wwwroot/app/settings/views/settingsTwoFactor.html +++ b/src/Web/wwwroot/app/settings/views/settingsTwoFactor.html @@ -29,7 +29,7 @@

-

3. Enter the resulting verification code from the app

+

3. Enter the resulting verification code from the app

- +

NOTE: After enabling two-step login, you will be required to enter the current code generated by your verification app each time you log in.