diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-02-10 17:55:13 +0100 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-02-10 17:55:13 +0100 |
| commit | bfac8211479dbeddd16d2044a4cf41d3ea592016 (patch) | |
| tree | 0dede18bc9b81995cad4008f1f8ca4da558bfd7e /client/js | |
| parent | 65bcc720596b395298fa281b5b68737d04ffdb8a (diff) | |
Optimize Identity
Diffstat (limited to 'client/js')
| -rw-r--r-- | client/js/controllers/login.js | 5 | ||||
| -rw-r--r-- | client/js/services/Identity.js | 16 |
2 files changed, 13 insertions, 8 deletions
diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index e9308b8..106e889 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -37,10 +37,7 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s $('#failedToLoginAlert').show(); } else { - $('#loginModal').modal('hide'); - Identity.profile.username=username; - Identity.profile.projectname=projectname; - + $('#loginModal').modal('hide'); } // Reset button state diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 2164592..7021003 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,11 +1,15 @@ mainApp.factory('Identity',[ '$http', function($http){ - var profile={}; - profile.username="None"; - profile.projectname="None"; + /* Create profile structure */ + var profile={}; + profile.username="Undefined"; + profile.projectname="Undefined"; + profile.token=""; + /** + * Function to connect to OpenStack * * @param {object} $http Angular $http service * @param {string} username The user name @@ -14,6 +18,9 @@ mainApp.factory('Identity',[ '$http', function($http){ * @returns {promise} The result of the request */ var login=function(username, password,projectname){ + profile.username=username; + profile.projectname=projectname; + return $http.post('../server/index.php', $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); }; @@ -29,7 +36,7 @@ mainApp.factory('Identity',[ '$http', function($http){ requestParserResult.status=0; requestParserResult.data=response.data; - + profile.token="Un Token"; // TODO @@ -39,6 +46,7 @@ mainApp.factory('Identity',[ '$http', function($http){ + // Return services objects return { login: login, parseLoginAnswer: parseLoginAnswer, |
