fix: magic link auth for chrome extension (#492)

The issue is whenever a user is trying to log in with an email and a one-time code, the Chrome extension is not able to authenticate. The fix is to add a callback URL with a query parameter of `extension-auth-success` equal to `true`, which will allow the Chrome extension to identify and verify the auth whenever a user is trying to log in into the Chrome extension.
This commit is contained in:
MaheshtheDev 2025-10-17 04:29:32 +00:00
parent 17fa79cba8
commit 90eea41ded

View file

@ -47,17 +47,20 @@ export function LoginPage({
// Create callback URL that includes redirect parameter if provided
const getCallbackURL = () => {
const origin = window.location.origin;
let finalUrl: URL;
if (redirectUrl) {
// Validate that the redirect URL is safe (same origin or allow external based on your security requirements)
try {
const url = new URL(redirectUrl, origin);
return url.toString();
finalUrl = new URL(redirectUrl, origin);
} catch {
// If redirect URL is invalid, fall back to origin
return origin;
finalUrl = new URL(origin);
}
} else {
finalUrl = new URL(origin);
}
return origin;
finalUrl.searchParams.set("extension-auth-success", "true");
return finalUrl.toString();
};
// Load last used method from localStorage on mount