summaryrefslogtreecommitdiff
path: root/client/js/services/Identity.js
blob: 21645929c2bc59f1a9c665e29ac54e1ae0a8496b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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	
	};

	
}]);