Skip to content

How to redirect users back to auth page if email is not verified? #240

Answered by burstWizard
burstWizard asked this question in Q&A
Discussion options

You must be logged in to vote

I solved it, and its a lot easier than I thought it would be.

To redirect users who haven't logged in, I just use AuthActions and withAuthUser, as described by the documentation.

To redirect users who have logged in or signed up, but don't have a verified email, I've put in this block of code:

if(AuthUser.id && !AuthUser.emailVerified){
        router.push("/verify")
        return <Loading />
}

It's not wrapped in a useEffect or anything, it's just inside the function component. I return the Loading component because router.push takes a little time, and the page will render if you don't return anything.

This works fine, but it would be really cool to be able to do this by just using nex…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@nmalancea
Comment options

@nmalancea
Comment options

@kmjennison
Comment options

@fanismahmalat
Comment options

@kmjennison
Comment options

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