Make Identity module more AngularJs Like !
This commit is contained in:
parent
1cd1ae92f4
commit
65bcc72059
7 changed files with 63 additions and 82 deletions
49
client/js/services/Identity.js
Normal file
49
client/js/services/Identity.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
mainApp.factory('Identity',[ '$http', function($http){
|
||||
var profile={};
|
||||
profile.username="None";
|
||||
profile.projectname="None";
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} $http Angular $http service
|
||||
* @param {string} username The user name
|
||||
* @param {string} password The user password
|
||||
* @param {string} projectname The user project name
|
||||
* @returns {promise} The result of the request
|
||||
*/
|
||||
var login=function(username, password,projectname){
|
||||
return $http.post('../server/index.php',
|
||||
$.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname}));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} response The response to parse
|
||||
* @returns {requestParserResult} Formated data
|
||||
*/
|
||||
var parseLoginAnswer=function(response){
|
||||
var requestParserResult={};
|
||||
|
||||
requestParserResult.status=0;
|
||||
requestParserResult.data=response.data;
|
||||
|
||||
|
||||
// TODO
|
||||
|
||||
|
||||
return requestParserResult;
|
||||
};
|
||||
|
||||
|
||||
|
||||
return {
|
||||
login: login,
|
||||
parseLoginAnswer: parseLoginAnswer,
|
||||
profile: profile
|
||||
};
|
||||
|
||||
|
||||
}]);
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
/**
|
||||
* The sharedProfile service
|
||||
* It's used to shared the profile between controller
|
||||
*/
|
||||
mainApp.factory('sharedProfile',[function(){
|
||||
var profile={};
|
||||
|
||||
profile.username="None";
|
||||
profile.projectname="None";
|
||||
|
||||
return profile;
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue