gpt4 book ai didi

javascript - 登录后重定向到仪表板 [EMBER.JS]

转载 作者:太空宇宙 更新时间:2023-11-04 15:27:56 25 4
gpt4 key购买 nike

我想在登录后重定向到用户仪表板,我该怎么做?目前我有一个注册页面和登录页面,但是在将其登录回登录和注册的主页后,我希望它转到仪表板,需要我在此处发布的任何文件

<小时/>

更新:

Controller /application.js

import Ember from 'ember';


export default Ember.Controller.extend({
session: Ember.inject.service('session'),

actions: {
invalidateSession() {
this.get('session').invalidate();
}
}
});

Controller /login.js

import Ember from 'ember';

export default Ember.Controller.extend({
session: Ember.inject.service('session'),

actions: {
authenticate() {
let { identification, password } =
this.getProperties('identification', 'password');
this.get('session').authenticate('authenticator:oauth2',
identification, password).catch((reason) => {
this.set('errorMessage', reason.error || reason);
});
}
}
});

route/application.js

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-
auth/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin, {
actions: {
invalidateSession() {
this.get('session').invalidate();
}
}

});

route/login.js

import Ember from 'ember';

export default Ember.Route.extend({
});

最佳答案

routeAfterAuthentication 添加到您的应用程序路由:

export default Ember.Route.extend(ApplicationRouteMixin, {

routeAfterAuthentication: 'dashboard',

actions: {
invalidateSession() {
this.get('session').invalidate();
}
}
}

https://ember-simple-auth.com/api/classes/ApplicationRouteMixin.html

关于javascript - 登录后重定向到仪表板 [EMBER.JS],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45066279/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com