登录后NuxtJS重定向

vue.js Vue.js

GOTony

2020-03-23

我正在使用nuxtjs和Laravel Passport。如果用户转到/ someurl,但登录方法推为'/',我如何将/ someurl存储在会话中,以便在登录时可以推入会话变量?我有一个称为的会话变量,但是在身份验证中间件中得到了刷新。我显然缺少了一些东西。这是我的代码:在auth.js中间件文件中

export default function ({ route, store, redirect }) {
let params = ''
if (!route.path.startsWith('/login') && !route.path.startsWith('/assets') && route.path !== '/') {
    store.state.requestUrl = route.path
}
if (!store.state.authenticated) {
    return redirect('/login')
}

并登录

await this.$store.dispatch('login', {
    username: this.loginDetails.username,
    password: this.loginDetails.password
})
    this.$router.push(this.$store.state.requestUrl) // this is always '/'
} catch (e) {
    console.log(e)
    this.failedLogin = true
}

第3137篇《登录后NuxtJS重定向》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android