mirror of
https://github.com/Febbweiss/CloudBudget-AngularJS.git
synced 2026-03-04 22:35:38 +00:00
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
(function(){
|
|
'use strict';
|
|
|
|
angular
|
|
.module('cloudbudget')
|
|
.controller('RegisterController', RegisterController);
|
|
|
|
RegisterController.$inject = ['UserService', '$location', '$rootScope', 'AuthenticationService', 'FlashService'];
|
|
|
|
function RegisterController(UserService, $location, $rootScope, AuthenticationService, FlashService) {
|
|
var vm = this;
|
|
|
|
vm.dataLoading = false;
|
|
vm.register = register;
|
|
|
|
function register() {
|
|
vm.dataLoading = true;
|
|
UserService.register(vm.user)
|
|
.then(function(response) {
|
|
if( response.success ) {
|
|
AuthenticationService.setCredentials(response.user);
|
|
FlashService.success('Registration successful', true);
|
|
$location.path('/accounts');
|
|
} else {
|
|
FlashService.error(response.message);
|
|
vm.dataLoading = false;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
})(); |