Ghost/core/client/app/controllers/signup.js
Kevin Ansfield 1bcd7fd333 Replace validation notifications with inline validations
issue #5409 & #5336

- update settings/general
- update signin
- update signup
- update edit user
- update reset password
- update setup/three
- remove `formatErrors` function from validationEngine mixin (it's no longer needed as inline validations should handle this instead)
2015-07-28 12:26:34 +01:00

54 lines
1.9 KiB
JavaScript

import Ember from 'ember';
import {request as ajax} from 'ic-ajax';
import ValidationEngine from 'ghost/mixins/validation-engine';
export default Ember.Controller.extend(ValidationEngine, {
// ValidationEngine settings
validationType: 'signup',
submitting: false,
ghostPaths: Ember.inject.service('ghost-paths'),
notifications: Ember.inject.service(),
actions: {
signup: function () {
var self = this,
model = this.get('model'),
data = model.getProperties('name', 'email', 'password', 'token'),
notifications = this.get('notifications');
notifications.closeNotifications();
this.validate().then(function () {
this.toggleProperty('submitting');
ajax({
url: self.get('ghostPaths.url').api('authentication', 'invitation'),
type: 'POST',
dataType: 'json',
data: {
invitation: [{
name: data.name,
email: data.email,
password: data.password,
token: data.token
}]
}
}).then(function () {
self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', {
identification: self.get('model.email'),
password: self.get('model.password')
});
}).catch(function (resp) {
self.toggleProperty('submitting');
notifications.showAPIError(resp);
});
}).catch(function (error) {
if (error) {
notifications.showAPIError(error);
}
});
}
}
});