framework/ember/app/controllers/signup.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-02-08 13:29:39 +08:00
import Ember from 'ember';
import ModalController from 'flarum/mixins/modal-controller';
2015-02-08 13:29:39 +08:00
export default Ember.Controller.extend(ModalController, {
emailProviderName: Ember.computed('welcomeUser.email', function() {
if (!this.get('welcomeUser.email')) { return; }
return this.get('welcomeUser.email').split('@')[1];
}),
emailProviderUrl: Ember.computed('emailProviderName', function() {
return 'http://'+this.get('emailProviderName');
}),
welcomeStyle: Ember.computed('welcomeUser.color', function() {
return 'background:'+this.get('welcomeUser.color');
}),
actions: {
submit: function() {
var data = this.getProperties('username', 'email', 'password');
var controller = this;
this.set('error', null);
this.set('loading', true);
2015-02-08 13:29:39 +08:00
var user = this.store.createRecord('user', data);
2015-02-08 13:29:39 +08:00
return user.save().then(function(user) {
controller.set('welcomeUser', user);
controller.set('loading', false);
controller.send('saveState');
}, function(reason) {
controller.set('loading', false);
});
}
}
2015-02-08 13:29:39 +08:00
});