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:
31
public/register/register.controller.js
Normal file
31
public/register/register.controller.js
Normal file
@@ -0,0 +1,31 @@
|
||||
(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('/');
|
||||
} else {
|
||||
FlashService.error(response.message);
|
||||
vm.dataLoading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user