summaryrefslogtreecommitdiff
path: root/client/js/controllers/login.js
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-10 21:46:18 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-10 21:46:18 +0100
commit8c6b1cecd310acebd63c73628688aa0fcf8cb126 (patch)
tree36529b1366bf65381aad98c6591336b0b80a8950 /client/js/controllers/login.js
parente026ce21b48eddc9c4ca03b441d03baff217d3ad (diff)
parent3f83cae4178226084dcbf1e826271a04cc97086d (diff)
Merge branch 'loic' into develop
Diffstat (limited to 'client/js/controllers/login.js')
-rw-r--r--client/js/controllers/login.js41
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);
+ });
+
}]);