mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
7ac6ebb920
issue #5409 - change persistent/passive notification status to alert/notification - replace showSuccess/Info/Warn/Error with showNotification/showAlert - fix and clean up notification/alert components
55 lines
1.9 KiB
JavaScript
55 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.toggleProperty('submitting');
|
|
this.validate({format: false}).then(function () {
|
|
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 (errors) {
|
|
self.toggleProperty('submitting');
|
|
if (errors) {
|
|
notifications.showErrors(errors);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|