core.controller('LoginController', function ($controller, $location, $scope, RestApi, StorageService, User) {
	
    angular.extend(this, $controller('AbstractController', {$scope: $scope}));
    
    $scope.account = {
    	email: '',
    	password: ''
    };

	$scope.login = function() {
		RestApi.anonymousGet({
			controller: 'auth',
			method: 'login',
			data: $scope.account
		}).then(function(data) {

			if(typeof data.payload.JWT == 'undefined') {
				console.log("User does not exist!");
			}
			else {
				StorageService.set("token", data.payload.JWT.tokenAsString);

				delete sessionStorage.role;

				var user = User.login();

				User.ready().then(function() {
					StorageService.set("role", user.role);
				});
			}
		});
	};

});
core.controller('LoginController', function ($controller, $location, $scope, RestApi, StorageService, User) {
	
    angular.extend(this, $controller('AbstractController', {$scope: $scope}));
    
    $scope.account = {
    	email: '',
    	password: ''
    };

	$scope.login = function() {
		RestApi.anonymousGet({
			controller: 'auth',
			method: 'login',
			data: $scope.account
		}).then(function(data) {

			if(typeof data.payload.JWT == 'undefined') {
				console.log("User does not exist!");
			}
			else {

				$scope.account = {
			    	email: '',
			    	password: ''
			    };
    
				StorageService.set("token", data.payload.JWT.tokenAsString);

				delete sessionStorage.role;

				var user = User.login();

				User.ready().then(function() {
					StorageService.set("role", user.role);
				});
			}
		});
	};

});
Clear login form upon login.
Clear login form upon login.
