Simplify Identity...

This commit is contained in:
manzerbredes 2016-02-10 19:27:28 +01:00
parent bfac821147
commit 0c98543594
2 changed files with 11 additions and 4 deletions

View file

@ -29,10 +29,10 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s
result.then(function (response){
// Parser result
var requestResultObject=Identity.parseLoginAnswer(response);
var response=Identity.getResponse();
// Check for error
if(requestResultObject.status!==0){
if(response.status!==0){
$('#failedToLoginAlert').show();
}

View file

@ -7,6 +7,8 @@ mainApp.factory('Identity',[ '$http', function($http){
profile.projectname="Undefined";
profile.token="";
/* Will contain the result of the $http request */
var $httpResponse;
/**
* Function to connect to OpenStack
@ -21,8 +23,9 @@ mainApp.factory('Identity',[ '$http', function($http){
profile.username=username;
profile.projectname=projectname;
return $http.post('../server/index.php',
$httpResponse=$http.post('../server/index.php',
$.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname}));
return $httpResponse;
};
@ -45,11 +48,15 @@ mainApp.factory('Identity',[ '$http', function($http){
};
var getResponse=function(){
return parseLoginAnswer($httpResponse);
}
// Return services objects
return {
login: login,
parseLoginAnswer: parseLoginAnswer,
getResponse: getResponse,
profile: profile
};