Drop new user component, for now
This commit is contained in:
parent
fb57534b64
commit
7c194447f7
4 changed files with 37 additions and 42 deletions
33
app/pods/users/new/controller.js
Normal file
33
app/pods/users/new/controller.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
passwordConfirm: null,
|
||||
|
||||
actions: {
|
||||
save: function() {
|
||||
let user = this.get('user');
|
||||
|
||||
// All validation is server-side, except for password verification matching
|
||||
if (user.get('password') !== this.get('passwordConfirm')) {
|
||||
this.get('flashMessages').clearMessages();
|
||||
this.get('flashMessages').error("Password fields don't match");
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.get('hasDirtyAttributes')) {
|
||||
user.save().then(() => {
|
||||
this.transitionTo('login').then(() => {
|
||||
this.get('flashMessages').information(`You have successfully signed up.
|
||||
Please check your email for further instructions.`);
|
||||
});
|
||||
}).catch(() => {
|
||||
// Manually clean up messages because there is no transition
|
||||
this.get('flashMessages').clearMessages();
|
||||
user.get('errors').forEach((error) => {
|
||||
this.get('flashMessages').error(`${error.attribute.capitalize()} - ${error.message}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
Reference in a new issue