Repository navigation
fix: handle getUser error - #3285
Conversation
mafredri
left a comment
There was a problem hiding this comment.
I'd like to see the 500 error changed, but other than that, backend looks good. 👍🏻
| const [authState, authSend] = useActor(xServices.authXService) | ||
| const isLoading = authState.hasTag("loading") | ||
| const redirectTo = retrieveRedirect(location.search) | ||
| const locationState = location.state ? (location.state as LocationState) : null |
There was a problem hiding this comment.
Do we need to use a ternary because of types? Or can we:
| const locationState = location.state ? (location.state as LocationState) : null | |
| const locationState = location.state ?? null |
There was a problem hiding this comment.
location.state can be null, but since we are typecasting it, the compiler thinks it is never null, so we are typecasting it only if it is not null.
| const navigateTo = isHomePage ? "/login" : embedRedirect(location.pathname) | ||
| if (authState.matches("signedOut")) { | ||
| return <Navigate to={navigateTo} /> | ||
| return <Navigate to={navigateTo} state={{ isRedirect: !isHomePage }} /> |
There was a problem hiding this comment.
does isRedirect replicate the functionality of embedRedirect?
There was a problem hiding this comment.
I think we could use one both to know whether to show the error and where to go next, but it might be better to keep them separate like this
There was a problem hiding this comment.
Yeah, we’d probably have to retrieve the redirect in the component but that didn’t seem like a very solid approach.
Building on #3241, this PR handles the
getUsererror fromauthXService.Special criteria: The error is only shown when redirecting to the
/loginpage from a page other than/. It is also not shown when loading the/loginpage directly.Subtasks
getUsererror above the Sign-in form/)You are signed out.orAn internal error occurredmessage and move the details in the error details section.Fixes #3088
Screenshot