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:
@@ -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();
|
||||
});
|
Reference in New Issue
Block a user