After a user has logged in the first time I redirect him to the page CreateProfile where he types in all the profile information. Afterwards I want to make this site not accessible anymore, such as if the user types the URL into the browser (e.g. www.myproject.com/createProfile).
How can I make sure that only the redirection from my login page has access to the CreateProfile page? That is, if the user types in the URL manually he will be redirected e.g. to the 404 page.
Currently my route for CreateProfile looks the following:
{
path: '/createprofile',
name: 'CreateProfile',
component: CreateProfile,
beforeEnter: (to, from, next) => {
if (store.getters.getUserStatus == true) {
next()
} else {
next({ name: 'Login' })
}
}
}
Thanks!!
Read more here: https://stackoverflow.com/questions/66262642/vue-router-access-route-only-from-certain-page
Content Attribution
This content was originally published by Chris at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.