fix: disabling login form while logging in

This commit is contained in:
Simone Margaritelli
2019-11-20 12:45:32 +01:00
parent 64f3082582
commit a3e86e1d72
4 changed files with 17 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@@ -63,7 +63,7 @@
<div ng-include src="'/views/modals/loader.html?v=7'"></div>
<!-- if user is not logged, show login -->
<div id="login" class="container" ng-if="!arc.IsLogged()" ng-include src="'/views/login.html?v=4'"></div>
<div id="login" class="container" ng-if="!arc.IsLogged()" ng-include src="'/views/login.html?v=5'"></div>
<!-- user logged but empty encryption key -->
<div ng-if="arc.IsLogged() && !key" style="margin-bottom:-10px; margin-top:10px;" class="alert alert-warning">

View File

@@ -228,6 +228,7 @@ app.controller('PMController', ['$scope', function (scope) {
scope.errorHandler = function(error) {
scope.hideLoader();
scope.setError(error);
scope.setLoginEnabled(true);
scope.$apply();
};
@@ -461,6 +462,13 @@ app.controller('PMController', ['$scope', function (scope) {
}
};
scope.setLoginEnabled = function(enabled) {
$('#loginButton').text(enabled ? 'Login' : 'Logging in ...');
$('#formLogin *').filter(':input').each(function(){
$(this).prop('disabled', !enabled);
});
};
scope.doLogin = function() {
scope.setStatus("Logging in ...");
@@ -468,7 +476,9 @@ app.controller('PMController', ['$scope', function (scope) {
var username = $('#username').val();
var password = $('#password').val();
if( scope.setKey( $('#key').val(), persist ) == true ) {
if( scope.setKey( $('#key').val(), persist ) == true ) {
scope.setLoginEnabled(false);
scope.arc.Login( username, password, persist, function(token) {
scope.setError(null);
scope.$apply();

View File

@@ -17,7 +17,8 @@
<input type="checkbox" id="persist" value="persist"/> Remember me.
</label>
<br/>
<button type="submit" class="btn btn-secondary float-right" ng-click="doLogin()">Login</button>
<button type="submit" class="btn btn-secondary float-right" ng-click="doLogin()"
id="loginButton">Login</button>
</form>
</div>
</div>