diff --git a/.changeset/rare-mails-flow.md b/.changeset/rare-mails-flow.md new file mode 100644 index 00000000..50964946 --- /dev/null +++ b/.changeset/rare-mails-flow.md @@ -0,0 +1,5 @@ +--- +"@openauthjs/openauth": patch +--- + +fix for password adapter not redirecting to the right place after change password flow diff --git a/packages/openauth/src/adapter/password.ts b/packages/openauth/src/adapter/password.ts index b12d1bb9..44f32be9 100644 --- a/packages/openauth/src/adapter/password.ts +++ b/packages/openauth/src/adapter/password.ts @@ -213,9 +213,8 @@ export function PasswordAdapter(config: PasswordConfig) { }) routes.get("/change", async (c) => { - const redirect = - c.req.query("redirect_uri") || - c.req.url.replace(/change.*/, "authorize") + let redirect = + c.req.query("redirect_uri") || getRelativeUrl(c, "./authorize") const state: PasswordChangeState = { type: "start", redirect, @@ -368,6 +367,7 @@ export function PBKDF2Hasher(opts?: { interations?: number }): PasswordHasher<{ } } import { timingSafeEqual, randomBytes, scrypt } from "node:crypto" +import { getRelativeUrl } from "../util.js" export function ScryptHasher(opts?: { N?: number