diff options
Diffstat (limited to 'client/js/controllers/login.js')
| -rw-r--r-- | client/js/controllers/login.js | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 2f74414..751bd09 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -1,39 +1,60 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ /** - * Represents a book. - * @constructor + * The login controler + * @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 + */ -mainApp.controller('loginCtrl', function ($scope,$interval,$sce) +mainApp.controller('loginCtrl', ['$scope','$sce','$http', 'sharedProfile', function ($scope,$sce, $http, sharedProfile) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); - $('#loadingLoginButton').hide(); - $('#failedToLoginAlert').hide(); - + // Define default states + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + $('#loadingLoginButton').hide(); + $('#failedToLoginAlert').hide(); + - $('#loginButton').click(function(){ + $('#loginButton').click(function(){ $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); + var username=$("#loginFormUsername").val(); + var password=$("#loginFormPassword").val(); + var projectname=$("#loginFormProjectname").val(); + + var result=identity.request.login($http,username, password, projectname); + + result.then(function (response){ + // Parser result + var requestResultObject=identity.requestParser.parseLoginAnswer(response); + + // Check for error + if(requestResultObject.status!==0){ + //alert(result.data) + $('#failedToLoginAlert').show(); + } + else { + $('#loginModal').modal('hide'); + sharedProfile.username=username; + sharedProfile.projectname=projectname; - $interval( - function() - { - $('#failedToLoginAlert').show(); + } + // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - - }, 2000,1); - + $('#loadingLoginButton').hide(); + },function(response){ + $('#failedToLoginAlert').show(); + + // Reset button state + $('#loginButton').show(); + $('#loadingLoginButton').hide(); + }); + }); -}) +}]); |
