-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] feat: add generalized redirect AuthAction #2
base: main
Are you sure you want to change the base?
Conversation
? onRedirect.whenAuthed | ||
: onRedirect.whenUnauthed | ||
|
||
if (!authStateConfig || !authStateConfig.destination) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!authStateConfig || !authStateConfig.destination) { | |
if (!authStateConfig?.destination) { |
Although that implies and - was the OR intentional before? Or were you intending to do:
if (authStateConfig && !authStateConfig.destination)
So that it is defined, but missing the destination. Thats what the error message seemed to imply anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe I'm misunderstanding since that seems to be what you do below?
|
||
if (!authStateConfig || !authStateConfig.destination) { | ||
throw new Error( | ||
`The "destination" in the "onRedirect.whenAuthed" and "onRedirect.whenUnauthed" redirect configs must resolve to a non-empty string` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We could technically make this only call out the offender here instead of both (with a conditional like you did above)
@@ -144,6 +145,39 @@ const withAuthUserTokenSSR = | |||
} | |||
} | |||
|
|||
if ([whenAuthed, whenUnauthed].includes(AuthAction.REDIRECT)) { | |||
const redirectConfig = onRedirect || getConfig().onRedirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - I like the overridable with local config with fallback to global
No description provided.