mirror of
https://github.com/Febbweiss/CloudBudget-AngularJS.git
synced 2026-03-04 22:35:38 +00:00
First commit
This commit is contained in:
32
public/login/login.controller.js
Normal file
32
public/login/login.controller.js
Normal file
@@ -0,0 +1,32 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('cloudbudget')
|
||||
.controller('LoginController', LoginController);
|
||||
|
||||
LoginController.$inject = ['$location', 'AuthenticationService', 'FlashService'];
|
||||
|
||||
function LoginController($location, AuthenticationService, FlashService) {
|
||||
var vm = this;
|
||||
|
||||
vm.login = login;
|
||||
|
||||
(function initController() {
|
||||
AuthenticationService.clearCredentials();
|
||||
})();
|
||||
|
||||
function login() {
|
||||
vm.dataLoading = true;
|
||||
AuthenticationService.login(vm.username, vm.password).then( function(response) {
|
||||
if( response.success ) {
|
||||
AuthenticationService.setCredentials(response.user);
|
||||
$location.path('/');
|
||||
} else {
|
||||
FlashService.error(response.message);
|
||||
vm.dataLoading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user