2015-02-08 13:29:39 +08:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
2015-02-10 15:35:40 +08:00
|
|
|
import ModalController from 'flarum/mixins/modal-controller';
|
2015-02-08 13:29:39 +08:00
|
|
|
|
2015-02-10 15:35:40 +08:00
|
|
|
export default Ember.Controller.extend(ModalController, {
|
2015-02-24 18:03:18 +08:00
|
|
|
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');
|
|
|
|
}),
|
|
|
|
|
2015-02-10 15:35:40 +08:00
|
|
|
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
|
|
|
|
2015-02-10 15:35:40 +08:00
|
|
|
var user = this.store.createRecord('user', data);
|
2015-02-08 13:29:39 +08:00
|
|
|
|
2015-02-24 18:03:18 +08:00
|
|
|
return user.save().then(function(user) {
|
|
|
|
controller.set('welcomeUser', user);
|
|
|
|
controller.set('loading', false);
|
2015-02-25 13:04:02 +08:00
|
|
|
controller.send('saveState');
|
2015-02-10 15:35:40 +08:00
|
|
|
}, function(reason) {
|
|
|
|
controller.set('loading', false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2015-02-08 13:29:39 +08:00
|
|
|
});
|