Skip to content

Best way to implement authentication (Oauth2) #1215

Answered by Mister-Hope
crixx asked this question in Q&A
Discussion options

You must be logged in to vote

You need to show your actual code.

If you use beforeRoute guard to perform redirect, then ssg will render any protected pages with login because your code told the renderer to render login page.

If you are logined and you no loger perform redirect when redirectly enter an protected page, then you are hygrating "the protected page content" on "the login page". So you will get a mismatch expected.

Is my description clear enough to you?

To perform such a feature, you may need to "mark the whole page" as client only and render blank content at ssr. Also place the redirect in onMounted lifecycle, check if the users are logined at that time, if not redirect to login page, if so render the conte…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@crixx
Comment options

@Mister-Hope
Comment options

Answer selected by crixx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants