summaryrefslogtreecommitdiff
path: root/client/js/controllers
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-05 17:47:53 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-05 17:47:53 +0100
commita16df328c05b3ac005a3c05237a069786b8d5d6f (patch)
tree5296ca6d9816568f939c0a22777e3c05c0b1defd /client/js/controllers
parent31f3a9d77fd3c2af679be75ddd2a4e18a3599082 (diff)
Make login part dynamic
Diffstat (limited to 'client/js/controllers')
-rw-r--r--client/js/controllers/login.js38
1 files changed, 24 insertions, 14 deletions
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();
-
- var result=identity.login($("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val());
+ $('#loginButton').hide();
+ $('#loadingLoginButton').show();
+ $('#failedToLoginAlert').hide();
-
- $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();
+ });
+
+
});
});