-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RestoreAuthState no longer functioning correctly #1892
Comments
Thanks for reporting this @o0charlie0o Looks like something's disconnected with the page render triggering. @dthyresson any initial thoughts on this one? |
Hi @o0charlie0o I'll look into this issue. To confirm, Are you setting the https://redwoodjs.com/docs/authentication#login-and-logout-options <Button
onClick={async () => {
if (isAuthenticated) {
await logOut({ returnTo: process.env.AUTH0_REDIRECT_URI })
} else {
const searchParams = new URLSearchParams(window.location.search)
await logIn({
appState: { targetUrl: searchParams.get('redirectTo') },
})
}
}}
>
{isAuthenticated ? 'Log out' : 'Log in'}
</Button> Or directly like: Also, could you confirm the version of the I do see some new feature re redirects here but not certain ti appleid (but the timing with the releases is similar): Thanks much. |
@dthyresson In this case I'm setting it directly to this.HISTORY_LISTENER_ID = gHistory.listen(() => {
this.setState(() => ({ context: this.getContext() }))
}) Doing a little research |
Did a little digging and compared location.js/tsx 26 vs 21: redwood/packages/router/src/location.js Line 16 in 53349fd
/// v0.26
getContext() {
const windowLocation =
typeof window !== 'undefined'
? window.location
: { pathname: '', search: '', hash: '' }
const { pathname, search, hash } = this.props.location || windowLocation
return { pathname, search, hash }
} and redwood/packages/router/src/location.js Line 16 in 53349fd
// v 0.21
getContext() {
const { pathname, search, hash } = this.props.location
return { pathname, search, hash }
} @dac09 or @Tobbe is anything related to |
Looks alright to me. If it's working in 0.21 and broken in 0.22 we should bisect that and see what changed. When/where are we executing the stuff in history.tsx? Is the export in internal.ts enough to trigger the code there? |
@dac09 @thedavidprice I think we should confirm if this is a bug and fix it for the next release. |
@peterp @thedavidprice @dac09 One thing that is clearly different between I ran some logs between the 2 branches and One thing I will mention is at first I was thinking it would be an issue with private routes but in my recreation Perhaps some changes in AuthProvider introduced this? |
Thanks so much for the detailed report here @o0charlie0o, there’s definitely some clues here that suggest to me it’s potentially to do with page loader. Any chance you could share a link to the repo to make it easier for me to reproduce? I’m going to add this to my list to investigate in-depth for next release, I’ve had my hands full with 0.27. I will ping back here with updates. |
@dac09 @dthyresson @thedavidprice @Tobbe @peterp FWIW I put in the following PR which fixes the issue for me. It's in a draft state now because I haven't tested it beyond my use case. I noticed in |
When returning to the app from Auth0 the correct
targetUrl
fromappState
is applied to the address bar but the app doesn't actually route to it. Props at the home route havecode
andstate
andpathname
fromuseLocation
still shows/
.This appears to have started happening in the
0.22.0
release. Was working correctly in0.21.0
. Still doesn't work correctly in the current release. I created a new project for testing to make sure it wasn't anything in our existing codebase causing the problem.You can see from the following screenshots I just came back from Auth0 and I'm seeing the home page rather than the after auth page as defined in the routes.
Then if I refresh the browser I get the correct page as expected.
The text was updated successfully, but these errors were encountered: