mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
Initial Commit
This commit is contained in:
commit
c92f737237
273 changed files with 16964 additions and 0 deletions
45
client/app/account/signup/signup.controller.js
Normal file
45
client/app/account/signup/signup.controller.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
import angular from 'angular';
|
||||
|
||||
export default class SignupController {
|
||||
user = {
|
||||
name: '',
|
||||
email: '',
|
||||
password: ''
|
||||
};
|
||||
errors = {};
|
||||
submitted = false;
|
||||
|
||||
|
||||
/*@ngInject*/
|
||||
constructor(Auth, $state) {
|
||||
this.Auth = Auth;
|
||||
this.$state = $state;
|
||||
}
|
||||
|
||||
register(form) {
|
||||
this.submitted = true;
|
||||
|
||||
if(form.$valid) {
|
||||
return this.Auth.createUser({
|
||||
name: this.user.name,
|
||||
email: this.user.email,
|
||||
password: this.user.password
|
||||
})
|
||||
.then(() => {
|
||||
// Account created, redirect to home
|
||||
this.$state.go('main');
|
||||
})
|
||||
.catch(err => {
|
||||
err = err.data;
|
||||
this.errors = {};
|
||||
// Update validity of form fields that match the mongoose errors
|
||||
angular.forEach(err.errors, (error, field) => {
|
||||
form[field].$setValidity('mongoose', false);
|
||||
this.errors[field] = error.message;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue