Fix: Preserve OAuth referer through email confirmation flow#6700
Fix: Preserve OAuth referer through email confirmation flow#6700bhatganeshdarshan wants to merge 1 commit intoopenstreetmap:masterfrom
Conversation
Store referer in session during signup to persist across requests. Pass referer through email confirmation links and transform to welcome_path with map parameters for signup emails. Clear referer from session after successful confirmation. Fixes issues where users would lose their original context after OAuth signup and email confirmation.
fbce83a to
e6f0e49
Compare
|
I'd say, we're already supporting this use case, and a code change is not required. However, since it isn't properly documented, I would focus on improving the documentation instead. See my comment here: #6699 (comment) |
|
So, in earlier discussions about this topic (linked in #6699), it was decided that after signup, the "welcome" page should still be shown after signup and before continuing with the authorization. Does this PR do or allow for that? |
|
Thanks for the feedback @mmd-osm I did find a separate issue where the OAuth referer is lost when using “Resend confirmation email”, and I’ve opened a new PR with tests for that: #6714 Is it okay if I close this PR and continue with the more targeted one? |
|
I don't see any issue with that, if it works best for you. |
Fix: Preserve OAuth referer through email confirmation flow
Changes
Fixes issue where newly created accounts couldn't complete OAuth2 authorization after email confirmation. Users were being redirected to the home page instead of the OAuth authorization page.
Fixes #6699
Description
This PR addresses a bug in the OAuth2 authorization flow that affects newly created accounts. When a user creates an account through an OAuth2 client (like StreetComplete) and confirms their email, they should be redirected to the OAuth authorization page to complete the flow. Instead, they were being redirected to the home page, preventing the authorization from completing.
Root Cause:
The OAuth referer URL was being lost during the email confirmation process. The referer parameter was either not stored in the session, transformed into a welcome path, or not retrieved after email confirmation.
Solution:
This PR modifies three controllers to properly preserve the OAuth referer throughout the entire flow:
The fix ensures that the original OAuth authorization URL is maintained through:
How has this been tested?
Test Environment:
Test Scenarios:
New account creation through OAuth flow:
/oauth2/authorize?client_id=TEST_CLIENT&response_type=codeVerified: User is correctly redirected to OAuth authorization page
Resend confirmation email:
Verified: User is correctly redirected to OAuth authorization page (previously redirected to home page)
Existing account login :
Verified: Still works correctly, redirects to OAuth authorization page
Non-OAuth signup :
/users/newVerified: User is redirected to welcome page as expected
All tests passed successfully with the changes applied.