Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Am I doing it right ? #236

Answered by csells
GitGud31 asked this question in Q&A
Dec 11, 2021 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

You can put all of your auth redirection logic into your top-level redirect function. In fact, it's already there. Your root route can just always forward:

GoRoute(
   name: 'root',
   path: '/',
   redirect: (_) => '/home/feed',
),

Your top-level and route-level redirect functions will keep being called until null is returned. In the case that the user is authenticated and headed to /home/feed, then your top-level redirect will return null and they're head to /home/feed as planned. If they're not authenticated, they'll have to authenticate first before they head to /home/feed. I believe that's the behavior you're after, correct?

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@GitGud31
Comment options

@pcelis19
Comment options

@GitGud31
Comment options

@danielmahon
Comment options

Comment options

You must be logged in to vote
1 reply
@GitGud31
Comment options

Answer selected by GitGud31
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