ENH: Set up ember-simple-auth (initial) (#12)

Fixes #6
This commit is contained in:
Matthew Ryan Dillon 2017-07-10 20:38:12 -07:00 committed by GitHub
parent 8897e35398
commit 75b75358cd
16 changed files with 200 additions and 34 deletions

21
app/controllers/login.js Normal file
View file

@ -0,0 +1,21 @@
import Ember from 'ember';
const { Controller, inject: { service } } = Ember;
export default Controller.extend({
session: service(),
flashMessages: service(),
actions: {
authenticate() {
this.transitionToRoute('loading').then(() => {
let { identification, password } = this.getProperties('identification', 'password');
this.get('session').authenticate('authenticator:application', identification, password).catch((reason) => {
this.transitionToRoute('login').then(() => {
this.get('flashMessages').danger(reason.non_field_errors || reason);
});
});
});
},
},
});