diff options
| author | Yoggzo <yogg@epsina.com> | 2016-02-08 17:10:24 +0100 |
|---|---|---|
| committer | Yoggzo <yogg@epsina.com> | 2016-02-08 17:10:24 +0100 |
| commit | f1585a13323d408b6917a514bed1920aec3780f0 (patch) | |
| tree | b98a23443d20af008cbb8eca16a7aff7c9aa823c /client/js/controllers/login.js | |
| parent | 43b65e1dbb53300d076f5885b5393ff68e248dd1 (diff) | |
| parent | 1cd1ae92f414573942262f65dc1644e8ff9bb8f6 (diff) | |
Merge branch 'develop' into Evan
mise a jour
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(); + }); + }); -}) +}]); |
