Redirect to requested page after login using vue-router

前端 未结 8 1939
臣服心动
臣服心动 2020-12-07 20:40

In my application some routes are just accessible for authenticated users.
When a unauthenticated user clicks on a link, for which he has to be signed in, he will be redi

8条回答
  •  萌比男神i
    2020-12-07 21:06

    Much easier with this library and login function is

    let redirect = this.$auth.redirect();
    this.$auth
      .login({
        data: this.model,
        rememberMe: true,
        redirect: { name: redirect ? redirect.from.name : "homepage",  query: redirect.from.query },
        fetchUser: true
      })
    

提交回复
热议问题