Skip to content

Commit

Permalink
Update the built-in UI callback as well
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh committed Dec 11, 2024
1 parent 72f5e13 commit d6c1053
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/auth-express/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,11 @@ export class ExpressAuth {
}
const verifier = req.cookies[this.options.pkceVerifierCookieName];
if (!verifier) {
throw new PKCEError("no pkce verifier cookie found");
// End user verified email from a different user agent than sign-up.
// This is fine, but the application will need to detect this and
// inform the end user that they will need to initiate a new sign up
// attempt to complete the flow.
return next();
}
const isSignUp = searchParams.get("isSignUp") === "true";
const tokenData = await (await this.core).getToken(code, verifier);
Expand Down
9 changes: 8 additions & 1 deletion packages/auth-nextjs/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,16 @@ export abstract class NextAuth extends NextAuthHelpers {
this.options.pkceVerifierCookieName,
)?.value;
if (!verifier) {
// End user verified email from a different user agent than
// sign-up. This is fine, but the application will need to detect
// this and inform the end user that they will need to initiate a
// new sign up attempt to complete the flow.
return onBuiltinUICallback(
{
error: new PKCEError("no pkce verifier cookie found"),
error: null,
tokenData: null,
provider: null,
isSignUp: false,
},
req,
);
Expand Down
9 changes: 8 additions & 1 deletion packages/auth-remix/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,15 @@ export class RemixServerAuth extends RemixClientAuth {
parseCookies(req)[this.options.pkceVerifierCookieName];

if (!verifier) {
// End user verified email from a different user agent than
// sign-up. This is fine, but the application will need to detect
// this and inform the end user that they will need to initiate a
// new sign up attempt to complete the flow.
return cbCall(onBuiltinUICallback, {
error: new PKCEError("no pkce verifier cookie found"),
error: null,
tokenData: null,
provider: null,
isSignUp: false,
});
}
const isSignUp = searchParams.get("isSignUp") === "true";
Expand Down
9 changes: 8 additions & 1 deletion packages/auth-sveltekit/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,15 @@ async function handleAuthRoutes(
const verifier = cookies.get(config.pkceVerifierCookieName);

if (!verifier) {
// End user verified email from a different user agent than sign-up.
// This is fine, but the application will need to detect this and inform
// the end user that they will need to initiate a new sign up attempt to
// complete the flow.
return onBuiltinUICallback({
error: new PKCEError("no pkce verifier cookie found"),
error: null,
tokenData: null,
provider: null,
isSignUp: false,
});
}
const isSignUp = searchParams.get("isSignUp") === "true";
Expand Down

0 comments on commit d6c1053

Please sign in to comment.