Ember-simple-auth会话在刷新页面时到期

时间:2018-10-10 05:26:46

标签: ember.js ember-cli

  

/应用程序/登录/ 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',
  };


....

当我使用必要的凭据登录时,它将路由到“配置文件路由” ,然后在刷新页面时,会话期满, 提出解决方案,

0 个答案:

没有答案