From cca5df968e3598b07ee81c1f7f2680f5b9120ec3 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Fri, 5 Feb 2016 19:35:38 +0100 Subject: Add sharedProfile service --- client/js/controllers/login.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'client/js/controllers/login.js') diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 07f1d19..3447ab1 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -3,24 +3,27 @@ * Represents a book. * @constructor */ -mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http) +mainApp.controller('loginCtrl', ['$scope','$sce','$http', 'sharedProfile', function ($scope,$sce, $http, sharedProfile) { // Define default states $('#loginModal').modal({backdrop: 'static', keyboard: false}); $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); - + $('#loginButton').click(function(){ $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); - var result=identity.request.login($http,$("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val()); + var username=$("#loginFormUsername").val(); + var password=$("#loginFormPassword").val(); + var projectname=$("#loginFormProjectname").val(); + + var result=identity.request.login($http,username, password, projectname); result.then(function (response){ - // Parser result var requestResultObject=identity.requestParser.parseLoginAnswer(response); @@ -31,21 +34,23 @@ mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http) } else { $('#loginModal').modal('hide'); + sharedProfile.username=username; + sharedProfile.projectname=projectname; + } // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); },function(response){ - $('#failedToLoginAlert').show(); // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); }); - + }); -}); +}]); -- cgit v1.2.3