diff --git a/client/index.html b/client/index.html
index fe53069..a4845e8 100644
--- a/client/index.html
+++ b/client/index.html
@@ -73,7 +73,6 @@
-
diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js
index d08a9f2..07f1d19 100644
--- a/client/js/controllers/login.js
+++ b/client/js/controllers/login.js
@@ -3,7 +3,7 @@
* Represents a book.
* @constructor
*/
-mainApp.controller('loginCtrl', function ($scope,$interval,$sce)
+mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http)
{
// Define default states
$('#loginModal').modal({backdrop: 'static', keyboard: false});
@@ -12,30 +12,40 @@ mainApp.controller('loginCtrl', function ($scope,$interval,$sce)
$('#loginButton').click(function(){
- $('#loginButton').hide();
- $('#loadingLoginButton').show();
- $('#failedToLoginAlert').hide();
+ $('#loginButton').hide();
+ $('#loadingLoginButton').show();
+ $('#failedToLoginAlert').hide();
- var result=identity.login($("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val());
-
-
- $interval(
- function()
- {
+ var result=identity.request.login($http,$("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val());
+
+
+ result.then(function (response){
+
+ // Parser result
+ var requestResultObject=identity.requestParser.parseLoginAnswer(response);
+
// Check for error
- if(!errors.checkForLogin(result)){
+ if(requestResultObject.status!==0){
+ //alert(result.data)
$('#failedToLoginAlert').show();
}
else {
$('#loginModal').modal('hide');
}
-
+
// Reset button state
$('#loginButton').show();
$('#loadingLoginButton').hide();
- }, 2000,1);
-
+ },function(response){
+
+ $('#failedToLoginAlert').show();
+ // Reset button state
+ $('#loginButton').show();
+ $('#loadingLoginButton').hide();
+ });
+
+
});
});
diff --git a/client/js/requests/errors.js b/client/js/requests/errors.js
deleted file mode 100644
index cc9389a..0000000
--- a/client/js/requests/errors.js
+++ /dev/null
@@ -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;
-};
\ No newline at end of file
diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js
index 61f06ed..59bbcf2 100644
--- a/client/js/requests/identity.js
+++ b/client/js/requests/identity.js
@@ -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;
+};