mirror of
https://github.com/Febbweiss/CloudBudget-AngularJS.git
synced 2026-03-04 22:35:38 +00:00
32 lines
989 B
JavaScript
32 lines
989 B
JavaScript
(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;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
})(); |