diff options
Diffstat (limited to 'client/js/controllers/login.js')
| -rw-r--r-- | client/js/controllers/login.js | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 60eb52f..6358a6d 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -4,7 +4,7 @@ * @param {$scope} $scope The $scope angular service * @param {$sce} $sce The $sce angular service * @param {$http} $http The $http angular service - * @param {sharedProfile} sharedProfile The sharedProfile service + * @param {Identity} The Identity service */ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) @@ -16,42 +16,39 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s $('#loginButton').click(function(){ + + // Begin login state for template $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); + // Get data from templates var username=$("#loginFormUsername").val(); var password=$("#loginFormPassword").val(); var projectname=$("#loginFormProjectname").val(); - var result=Identity.login(username, password, projectname); - - - result.then(function (response){ - // Parser result - var response=Identity.getResponse(); - - // Check for error + // Function to call to handle result + var responseCallback=function(response){ + if(response.status!==0){ - + // Set reason of fail + $scope.failReason=response.failReason; + + // Display the error $('#failedToLoginAlert').show(); } else { + // Else the user is online ! $('#loginModal').modal('hide'); } // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - },function(response){ - $('#failedToLoginAlert').show(); - - // Reset button state - $('#loginButton').show(); - $('#loadingLoginButton').hide(); - }); - - - - }); + $('#loadingLoginButton').hide(); + } + + // Try to login + Identity.login(username, password, projectname, responseCallback); + }); + }]); |
