Improve login dialog.
This commit is contained in:
parent
3697ff9f21
commit
86911c106d
@ -47,21 +47,20 @@ var loginModule = angular.module('accountant.login', [
|
|||||||
ariaDescribedBy: 'modal-body',
|
ariaDescribedBy: 'modal-body',
|
||||||
templateUrl: loginTmpl,
|
templateUrl: loginTmpl,
|
||||||
controller: 'LoginModalController',
|
controller: 'LoginModalController',
|
||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl'
|
||||||
size: 'lg',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modalInstance.result.then(function (data) {
|
modalInstance.result.then(function (data) {
|
||||||
$log.log(data);
|
$log.log(data);
|
||||||
|
|
||||||
// TODO Alexis Lahouze 2015-08-28 Handle callback.
|
|
||||||
// Call to /api/login to retrieve the token
|
|
||||||
$storage.session.set('refresh_token', data.refresh_token);
|
$storage.session.set('refresh_token', data.refresh_token);
|
||||||
$storage.session.set('access_token', data.access_token);
|
$storage.session.set('access_token', data.access_token);
|
||||||
|
|
||||||
authService.loginConfirmed();
|
authService.loginConfirmed();
|
||||||
}, function () {
|
}, function () {
|
||||||
$log.info('Modal dismissed at: ' + new Date());
|
$log.info('Modal dismissed at: ' + new Date());
|
||||||
|
|
||||||
|
// FIXME Alexis Lahouze 2017-06-11 Redirect to error page.
|
||||||
authService.loginCancelled(null, 'Login cancelled by user action.');
|
authService.loginCancelled(null, 'Login cancelled by user action.');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -121,8 +120,7 @@ var loginModule = angular.module('accountant.login', [
|
|||||||
var email = vm.data.email;
|
var email = vm.data.email;
|
||||||
var password = vm.data.password;
|
var password = vm.data.password;
|
||||||
|
|
||||||
$log.log(email, password);
|
// Encode authentication data.
|
||||||
|
|
||||||
var authdata = base64.encode(email + ':' + password);
|
var authdata = base64.encode(email + ':' + password);
|
||||||
|
|
||||||
return $http.post('/api/user/login', {}, {
|
return $http.post('/api/user/login', {}, {
|
||||||
@ -133,6 +131,9 @@ var loginModule = angular.module('accountant.login', [
|
|||||||
$log.log(result);
|
$log.log(result);
|
||||||
|
|
||||||
$uibModalInstance.close(result.data);
|
$uibModalInstance.close(result.data);
|
||||||
|
}, function(response) {
|
||||||
|
// FIXME Alexis Lahouze 2017-06-11 Handle error.
|
||||||
|
$log.log("Error on login", response);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user