Drop custom session
This commit is contained in:
parent
6f6faee122
commit
4c8cbd20c7
6 changed files with 30 additions and 37 deletions
|
@ -4,7 +4,10 @@ import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
|
|||
export default Ember.Route.extend(ApplicationRouteMixin, {
|
||||
actions: {
|
||||
invalidateSession: function() {
|
||||
this.get('session').invalidate();
|
||||
this.get('session').invalidate().then(() => {
|
||||
// Wait until promise is resolved
|
||||
return true;
|
||||
});
|
||||
},
|
||||
|
||||
didTransition: function() {
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
import Ember from 'ember';
|
||||
import parseBase64 from '../../utils/parse-base64';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
actions: {
|
||||
authenticate: function() {
|
||||
let credentials = this.getProperties('identification', 'password');
|
||||
let session = this.get('session');
|
||||
let authenticator = 'simple-auth-authenticator:token';
|
||||
|
||||
this.set('loading', true);
|
||||
// Manually clean up because there might not be a transition
|
||||
this.get('flashMessages').clearMessages();
|
||||
this.get('session').authenticate(authenticator, credentials).then(()=>{
|
||||
session.authenticate(authenticator, credentials).then(()=>{
|
||||
this.set('loading', false);
|
||||
let t = parseBase64(session.get('secure.token'));
|
||||
this.store.find('user', t['sub']).then((user) => {
|
||||
session.set('currentUser', user);
|
||||
});
|
||||
}, (error)=> {
|
||||
this.set('loading', false);
|
||||
this.get('flashMessages').error(error.error);
|
||||
|
|
Reference in a new issue