From 822a4ae776552aa4bd4237cfebef410a4b17b041 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Mon, 4 Feb 2019 16:47:43 +0100 Subject: [PATCH] Closes #268: test TOTP after activation --- .../controller/settings/SettingsSecurity.js | 18 +++++++++++-- docs-web/src/main/webapp/src/locale/en.json | 5 +++- .../src/partial/docs/settings.security.html | 26 ++++++++++++++----- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js index c1e2a0d7..357d558e 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js @@ -11,7 +11,7 @@ angular.module('docs').controller('SettingsSecurity', function($scope, User, $di /** * Enable TOTP. */ - $scope.enableTotp = function() { + $scope.enableTotp = function () { var title = $translate.instant('settings.security.enable_totp'); var msg = $translate.instant('settings.security.enable_totp_message'); var btns = [ @@ -34,7 +34,7 @@ angular.module('docs').controller('SettingsSecurity', function($scope, User, $di /** * Disable TOTP. */ - $scope.disableTotp = function() { + $scope.disableTotp = function () { $uibModal.open({ templateUrl: 'partial/docs/settings.security.disabletotp.html', controller: 'SettingsSecurityModalDisableTotp' @@ -53,4 +53,18 @@ angular.module('docs').controller('SettingsSecurity', function($scope, User, $di }); }); }; + + /** + * Test TOTP. + */ + $scope.testValidationCodeSuccess = null; + $scope.testTotp = function (code) { + Restangular.one('user/test_totp').post('', { + code: code + }).then(function() { + $scope.testValidationCodeSuccess = true; + }, function () { + $scope.testValidationCodeSuccess = false; + }); + }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/locale/en.json b/docs-web/src/main/webapp/src/locale/en.json index 7556e882..e9df206a 100644 --- a/docs-web/src/main/webapp/src/locale/en.json +++ b/docs-web/src/main/webapp/src/locale/en.json @@ -347,7 +347,10 @@ "message": "Your account will not be protected by the two-factor authentication anymore.", "confirm_password": "Confirm your password", "submit": "Disable two-factor authentication" - } + }, + "test_totp": "Please enter the validation code displayed on your phone :", + "test_code_success": "Validation code OK", + "test_code_fail": "This code is not valid, please double check that your phone is properly configured or disable Two-factor authentication" }, "group": { "title": "Groups management", diff --git a/docs-web/src/main/webapp/src/partial/docs/settings.security.html b/docs-web/src/main/webapp/src/partial/docs/settings.security.html index 94ab86e3..84276fea 100644 --- a/docs-web/src/main/webapp/src/partial/docs/settings.security.html +++ b/docs-web/src/main/webapp/src/partial/docs/settings.security.html @@ -19,12 +19,26 @@
-
-

- -

- {{ 'settings.security.secret_key_warning' | translate }} -

+
+
+

+ +

+ {{ 'settings.security.secret_key_warning' | translate }} +

+
+
+

{{ 'settings.security.test_totp' | translate }}

+
+ + +
+

+ {{ 'settings.security.test_code_success' | translate }} + {{ 'settings.security.test_code_fail' | translate }} +

+