From 98350860eb7a166adc5d5c124f3476d473300eb7 Mon Sep 17 00:00:00 2001 From: jendib Date: Thu, 24 Mar 2016 00:03:29 +0100 Subject: [PATCH] #84: Ask for a TOTP validation code (web UI) --- .../webapp/src/app/docs/controller/Login.js | 22 ++++++++++++++----- .../main/webapp/src/partial/docs/login.html | 9 ++++++++ docs-web/src/main/webapp/src/style/main.less | 6 ++++- .../src/main/webapp/style/theme/default.less | 0 4 files changed, 30 insertions(+), 7 deletions(-) delete mode 100644 docs-web/src/main/webapp/style/theme/default.less diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Login.js b/docs-web/src/main/webapp/src/app/docs/controller/Login.js index 9c695aa3..9a5fb7ce 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Login.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Login.js @@ -4,18 +4,28 @@ * Login controller. */ angular.module('docs').controller('Login', function($scope, $rootScope, $state, $dialog, User) { + $scope.codeRequired = false; + + /** + * Login. + */ $scope.login = function() { User.login($scope.user).then(function() { User.userInfo(true).then(function(data) { $rootScope.userInfo = data; }); $state.go('document.default'); - }, function() { - var title = 'Login failed'; - var msg = 'Username or password invalid'; - var btns = [{result:'ok', label: 'OK', cssClass: 'btn-primary'}]; - - $dialog.messageBox(title, msg, btns); + }, function(data) { + if (data.data.type == 'ValidationCodeRequired') { + // A TOTP validation code is required to login + $scope.codeRequired = true; + } else { + // Login truly failed + var title = 'Login failed'; + var msg = 'Username or password invalid'; + var btns = [{result: 'ok', label: 'OK', cssClass: 'btn-primary'}]; + $dialog.messageBox(title, msg, btns); + } }); }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/login.html b/docs-web/src/main/webapp/src/partial/docs/login.html index 4aabda53..d03c33ed 100644 --- a/docs-web/src/main/webapp/src/partial/docs/login.html +++ b/docs-web/src/main/webapp/src/partial/docs/login.html @@ -17,6 +17,15 @@ + + A validation code is required + + +
+ + +
+