【发布时间】:2015-12-01 22:10:20
【问题描述】:
伙计们,
我一直试图让 ESA 在登录和注销事件后重定向到特定页面,但没有成功。
我试图通过覆盖“sessionAuthenticated”方法来做到这一点,但也尝试设置“routeAfterConfiguration”设置,但没有成功。
目前,登录将我发送到“/”,注销将应用发送到“/undefined”。
我使用 simple-auth-token 作为 JWT 身份验证器策略。
我的应用程序路由的代码如下所示...
import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(ApplicationRouteMixin,{
actions: {
sessionAuthenticated: function() {
console.log('sessionAuthenticated: authentications ok');
window.location.replace('/profile');
},
},
});
我的login.js如下:
import Ember from 'ember';
const {service} = Ember.inject;
export default Ember.Route.extend({
session: service('session'),
errorMessage: null,
model: function(){
return Ember.Object.create({
identification:'',
password: '',
errorMessage: this.get('errorMessage')
});
},
setupController: function(controller, model) {
controller.set('credentials',model);
},
actions: {
authenticate: function(credentials) {
console.log(credentials);
this.get('session').authenticate('simple-auth-authenticator:jwt', credentials)
.catch((reason) => {
console.log('Login Error');
credentials.set('errorMessage', reason);
});
},
},
});
有人知道我在这里做错了什么吗?
干杯,
安迪
【问题讨论】:
-
您能发布任何与简单身份验证相关的其他代码吗?您的登录操作、任何自定义身份验证器(或让我们知道您正在使用哪个内置身份验证器)以及与简单身份验证相关的 ENV 配置。你也应该使用
this.transitionTo('profile');而不是window.location.replace -
谢谢汤姆。更多细节在上面编辑...
标签: ember.js login ember-simple-auth