fix(auth): allow_register was not respected in strategy controllers

This commit is contained in:
dswbx
2025-12-06 20:51:09 +01:00
parent 4f7925dfd8
commit 09b9a5e857
4 changed files with 50 additions and 37 deletions

View File

@@ -284,7 +284,7 @@ export class OAuthStrategy extends AuthStrategy<typeof schemaProvided> {
}
}
getController(auth: Authenticator): Hono<any> {
getController(auth: Authenticator, opts: { allow_register?: boolean }): Hono<any> {
const hono = new Hono();
const secret = "secret";
const cookie_name = "_challenge";
@@ -379,6 +379,10 @@ export class OAuthStrategy extends AuthStrategy<typeof schemaProvided> {
return c.notFound();
}
if (action === "register" && !opts.allow_register) {
return c.notFound();
}
const url = new URL(c.req.url);
const path = url.pathname.replace(`/${action}`, "");
const redirect_uri = url.origin + path + "/callback";