mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 23:27:57 +01:00
#84: Ask for a TOTP validation code (web UI)
This commit is contained in:
parent
1343948d33
commit
98350860eb
@ -4,18 +4,28 @@
|
|||||||
* Login controller.
|
* Login controller.
|
||||||
*/
|
*/
|
||||||
angular.module('docs').controller('Login', function($scope, $rootScope, $state, $dialog, User) {
|
angular.module('docs').controller('Login', function($scope, $rootScope, $state, $dialog, User) {
|
||||||
|
$scope.codeRequired = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login.
|
||||||
|
*/
|
||||||
$scope.login = function() {
|
$scope.login = function() {
|
||||||
User.login($scope.user).then(function() {
|
User.login($scope.user).then(function() {
|
||||||
User.userInfo(true).then(function(data) {
|
User.userInfo(true).then(function(data) {
|
||||||
$rootScope.userInfo = data;
|
$rootScope.userInfo = data;
|
||||||
});
|
});
|
||||||
$state.go('document.default');
|
$state.go('document.default');
|
||||||
}, function() {
|
}, 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 title = 'Login failed';
|
||||||
var msg = 'Username or password invalid';
|
var msg = 'Username or password invalid';
|
||||||
var btns = [{result: 'ok', label: 'OK', cssClass: 'btn-primary'}];
|
var btns = [{result: 'ok', label: 'OK', cssClass: 'btn-primary'}];
|
||||||
|
|
||||||
$dialog.messageBox(title, msg, btns);
|
$dialog.messageBox(title, msg, btns);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
@ -17,6 +17,15 @@
|
|||||||
<input class="form-control" type="password" id="inputPassword" placeholder="Password" ng-model="user.password" />
|
<input class="form-control" type="password" id="inputPassword" placeholder="Password" ng-model="user.password" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<span class="help-block" ng-if="codeRequired">
|
||||||
|
A validation code is required
|
||||||
|
<span class="glyphicon glyphicon-question-sign" title="You have activated the two-factor authentication on your account. Please enter a validation code generated by the phone app your configured."></span>
|
||||||
|
</span>
|
||||||
|
<div class="form-group" ng-if="codeRequired">
|
||||||
|
<label class="sr-only" for="inputCode">Validation code</label>
|
||||||
|
<input class="form-control" type="text" id="inputCode" placeholder="Validation code" ng-model="user.code" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" ng-model="user.remember" /> Remember me
|
<input type="checkbox" ng-model="user.remember" /> Remember me
|
||||||
|
@ -240,7 +240,11 @@ input[readonly].share-link {
|
|||||||
.login-box {
|
.login-box {
|
||||||
background: rgba(255, 255, 255, 0.5);
|
background: rgba(255, 255, 255, 0.5);
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border-radius: 4px
|
border-radius: 4px;
|
||||||
|
|
||||||
|
.help-block, .checkbox {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Styling for the ngProgress itself */
|
/* Styling for the ngProgress itself */
|
||||||
|
Loading…
Reference in New Issue
Block a user