Make login part dynamic

This commit is contained in:
manzerbredes 2016-02-05 17:47:53 +01:00
parent 31f3a9d77f
commit a16df328c0
4 changed files with 43 additions and 64 deletions

View file

@ -1,14 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var errors={};
errors.checkForLogin=function(result){
// TODO
return true;
};

View file

@ -1,47 +1,31 @@
// Make Namespace
var identity = {};
identity.request = {}; // Request part
identity.requestParser = {}; // Parser part
identity.login=function(username, projectname, password){
identity.request.login=function($http,username, projectname, password){
var requestResultObject={};
// Todo
return "tokens";
return $http.post('http://localhost.istic-openstack/server/index.php',
$.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname}),
{headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}});
};
/*
mainApp.controller('identityCtrl', function($scope, $http) {
$scope.identityFormData = {};
$scope.processForm = function() {
$http({
method : 'POST',
url : 'http://148.60.11.31/',
data : $.param($scope.identityFormData),
headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
})
.success(function(data) {
console.log(data);
if (!data.success) {
// if not successful, bind errors to error variables
//$scope.errorName = data.errors.name;
//$scope.errorSuperhero = data.errors.superheroAlias;
} else {
// if successful, bind success message to message
//$scope.message = data.message;
}
});
};
});*/
identity.requestParser.parseLoginAnswer=function(response){
var requestParserResult={};
requestParserResult.status=0;
requestParserResult.data=response.data;
// TODO
return requestParserResult;
};