GUAC-919: Rename LoginRESTService to TokenRESTService and provide logout semantics. Move Angular auth stuff to own module. Actually logout user.

This commit is contained in:
Michael Jumper
2014-11-05 12:10:05 -08:00
parent 68a9a4f6dc
commit 6bea1eed44
11 changed files with 152 additions and 56 deletions

View File

@@ -24,22 +24,14 @@ angular.module('login').controller('loginController', ['$scope', '$injector',
function loginController($scope, $injector) {
// Get the dependencies commonJS style
var authenticationService = $injector.get("authenticationService");
var localStorageUtility = $injector.get("localStorageUtility");
var $location = $injector.get("$location");
var authenticationService = $injector.get("authenticationService");
var $location = $injector.get("$location");
// Clear the auth token and userID to log out the user
localStorageUtility.clear("authToken");
localStorageUtility.clear("userID");
$scope.loginError = false;
$scope.login = function login() {
authenticationService.login($scope.username, $scope.password)
.success(function success(data, status, headers, config) {
localStorageUtility.set('authToken', data.authToken);
localStorageUtility.set('userID', data.userID);
// Set up the basic permissions for the user
$scope.loadBasicPermissions();
$location.path('/');
@@ -47,4 +39,5 @@ angular.module('login').controller('loginController', ['$scope', '$injector',
$scope.loginError = true;
});
};
}]);