Login Service complete !

This commit is contained in:
manzerbredes 2016-02-10 21:45:52 +01:00
parent 0c98543594
commit 3f83cae417
6 changed files with 94 additions and 61 deletions

View file

@ -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);
});
}]);

View file

@ -4,7 +4,7 @@
* The status controller
*
* @param {$scope} $scope The $scope service from angular
* @param {sharedProfile} sharedProfile The sharedProfile build by ourself
* @param {Identity} The Identity service
*/
mainApp.controller('statusCtrl', ['$scope','Identity', function ($scope, Identity)
{