From 86911c106d51eaa1ee85d47b34d0b5c08ea2847d Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sun, 11 Jun 2017 01:14:26 +0200 Subject: [PATCH] Improve login dialog. --- src/login/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/login/index.js b/src/login/index.js index df0acc3..a6fc331 100644 --- a/src/login/index.js +++ b/src/login/index.js @@ -47,21 +47,20 @@ var loginModule = angular.module('accountant.login', [ ariaDescribedBy: 'modal-body', templateUrl: loginTmpl, controller: 'LoginModalController', - controllerAs: '$ctrl', - size: 'lg', + controllerAs: '$ctrl' }); modalInstance.result.then(function (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('access_token', data.access_token); authService.loginConfirmed(); }, function () { $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.'); }); }; @@ -121,8 +120,7 @@ var loginModule = angular.module('accountant.login', [ var email = vm.data.email; var password = vm.data.password; - $log.log(email, password); - + // Encode authentication data. var authdata = base64.encode(email + ':' + password); return $http.post('/api/user/login', {}, { @@ -133,6 +131,9 @@ var loginModule = angular.module('accountant.login', [ $log.log(result); $uibModalInstance.close(result.data); + }, function(response) { + // FIXME Alexis Lahouze 2017-06-11 Handle error. + $log.log("Error on login", response); }); };