Skip to content
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

Login redirect should respect /?next= queryparam #52

Open
AlmerCarbonEquity opened this issue Jan 10, 2025 · 1 comment
Open

Login redirect should respect /?next= queryparam #52

AlmerCarbonEquity opened this issue Jan 10, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@AlmerCarbonEquity
Copy link
Contributor

When you login using a passkey, it should take you to the page you originally tried to visit. Workaround I use is to store it in the session and override the get_success_data method from CompleteCredentialAuthenticationView to retrieve it.

@Stormheg
Copy link
Member

Stormheg commented Feb 7, 2025

@AlmerCarbonEquity it is not documented, but this already is a feature. Except it looks for a hidden next input on the page instead of a URL parameter. I agree with you that it should also look out for a next parameter in the URL. Not sure which on should takes precedence, let's see what Django does and replicate that.

// Find out if there is a hidden 'next' field on the page
const next = document.querySelector(
"input[name='next']",
) as HTMLInputElement;
let completeAuthenticationUrl = config.completeAuthenticationUrl;
if (next && next.value) {
completeAuthenticationUrl += `?next=${encodeURIComponent(next.value)}`;
}
and
// Find out if there is a hidden 'next' field on the page
const next = document.querySelector(
"input[name='next']",
) as HTMLInputElement;
let completeAuthenticationUrl = config.completeAuthenticationUrl;
if (next && next.value) {
completeAuthenticationUrl += `?next=${encodeURIComponent(next.value)}`;
}

(also a good opportunity to de-duplicate this code and extract it into it's own utility function)

Feel free to open a pull request

@Stormheg Stormheg added the enhancement New feature or request label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants