1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 16:36:47 +02:00

Add ember-simple-auth, setup login

- Allow dropdown-buttons to render a partial
This commit is contained in:
Toby Zerner
2015-01-30 12:21:18 +10:30
parent 9886fb1f7a
commit c2feae406d
17 changed files with 334 additions and 69 deletions

View File

@@ -1,11 +1,32 @@
import Ember from 'ember';
// import NotificationMessage from '../models/notification-message';
import AuthenticationControllerMixin from 'simple-auth/mixins/authentication-controller-mixin';
// export default Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin, Ember.Evented, {
export default Ember.Controller.extend(AuthenticationControllerMixin, {
// authenticatorFactory: 'authenticator:flarum'
authenticator: 'authenticator:flarum',
actions: {
authenticate: function() {
var data = this.getProperties('identification', 'password');
var controller = this;
this.set('error', null);
this.set('loading', true);
return this._super(data).then(function() {
controller.send("sessionChanged");
}).catch(function(errors) {
switch(errors[0].code) {
case 'invalidLogin':
controller.set('error', 'Your login details are incorrect.');
break;
default:
controller.set('error', 'Something went wrong. (Error code: '+errors[0].code+')');
}
}).finally(function() {
controller.set('loading', false);
});
}
}
// });
export default Ember.Controller.extend();
});