/应用程序/登录/ 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',
};
....
当我使用必要的凭据登录时,它将路由到“配置文件路由” ,然后在刷新页面时,会话期满, 提出解决方案,