blob: 509f800f5cc98ac4881c59fc828339163343d6d1 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
mainApp.factory('Identity',[ '$http', function($http){
/* Create profile structure */
var profile={};
profile.username="Undefined";
profile.projectname="Undefined";
profile.token="";
/* Will contain the result of the $http request */
var $httpResponse;
/**
* Function to connect to OpenStack
*
* @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){
profile.username=username;
profile.projectname=projectname;
$httpResponse=$http.post('../server/index.php',
$.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname}));
return $httpResponse;
};
/**
*
* @param {string} response The response to parse
* @returns {requestParserResult} Formated data
*/
var parseLoginAnswer=function(response){
var requestParserResult={};
requestParserResult.status=0;
requestParserResult.data=response.data;
profile.token="Un Token";
// TODO
return requestParserResult;
};
var getResponse=function(){
return parseLoginAnswer($httpResponse);
}
// Return services objects
return {
login: login,
getResponse: getResponse,
profile: profile
};
}]);
|