mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 06:25:51 +03:00
aceb63c973
closes #3081 - added route `/ghost/api/v0.1/authentication/invitation` - added accept invitation - added signup with token - removed check() from users api - fixed promise in resetPassword()
56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
import ajax from 'ghost/utils/ajax';
|
|
import ValidationEngine from 'ghost/mixins/validation-engine';
|
|
|
|
var SignupController = Ember.ObjectController.extend(ValidationEngine, {
|
|
name: null,
|
|
email: null,
|
|
password: null,
|
|
token: null,
|
|
submitting: false,
|
|
|
|
// ValidationEngine settings
|
|
validationType: 'signup',
|
|
|
|
actions: {
|
|
signup: function () {
|
|
var self = this,
|
|
data = self.getProperties('name', 'email', 'password', 'token');
|
|
|
|
self.notifications.closePassive();
|
|
|
|
this.toggleProperty('submitting');
|
|
this.validate({ format: false }).then(function () {
|
|
ajax({
|
|
url: self.get('ghostPaths').apiUrl('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('ember-simple-auth-authenticator:oauth2-password-grant', {
|
|
identification: self.get('email'),
|
|
password: self.get('password')
|
|
}).then(function () {
|
|
self.send('signedIn');
|
|
self.transitionToRoute(Ember.SimpleAuth.routeAfterAuthentication);
|
|
});
|
|
}, function (resp) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showAPIError(resp);
|
|
});
|
|
}, function (errors) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showErrors(errors);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default SignupController;
|