mardi 9 octobre 2018

Ember-simple-auth Session Expiring when I refresh the Page

/ app / login / controller.js

import Controller from '@ember/controller';
import { inject } from '@ember/service';

export default Controller.extend({
    session: inject('session'),
    actions: {
        authenticate: function(){
            // let _this = this;
            let credentials = this.getProperties('identification','password');
            let authenticator = 'authenticator:jwt';
            this.get('session').authenticate(authenticator, credentials).catch((reason)=>{
                // this.set('errorMessage', reason.error || reason);
                this.set('errorMessage','Login Failed');
            });
        }
    }
});

/app / profile / controller.js

import Controller from '@ember/controller';
import { inject } from '@ember/service';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

export default Controller.extend(AuthenticatedRouteMixin, {
    session: inject('session'),
});

/ config / environment.js

.....

ENV['ember-simple-auth'] = {
    authorizer: 'authorizer:custom',
    routeAfterAuthentication: '/profiles',
  };


....

When I logged in with the necessary credentials it will route to the Profile Route and then when I refresh the page, the session expires, Suggest a solution,




Aucun commentaire:

Enregistrer un commentaire