diff --git a/app/__test__/auth/middleware.spec.ts b/app/__test__/auth/middleware.spec.ts index 77ecfab..d7e3f30 100644 --- a/app/__test__/auth/middleware.spec.ts +++ b/app/__test__/auth/middleware.spec.ts @@ -3,7 +3,7 @@ import { shouldSkipAuth } from "../../src/auth/middlewares"; describe("auth middleware", () => { it("should skip auth on asset paths", () => { - expect(shouldSkipAuth({ req: new Request("http://localhost/assets/test.js") })).toBe(true); - expect(shouldSkipAuth({ req: new Request("http://localhost/") })).toBe(false); + expect(shouldSkipAuth(new Request("http://localhost/assets/test.js"))).toBe(true); + expect(shouldSkipAuth(new Request("http://localhost/"))).toBe(false); }); }); diff --git a/app/src/auth/AppAuth.ts b/app/src/auth/AppAuth.ts index a0105a6..0608063 100644 --- a/app/src/auth/AppAuth.ts +++ b/app/src/auth/AppAuth.ts @@ -276,6 +276,10 @@ export class AppAuth extends Module { } async createUser({ email, password, ...additional }: CreateUserPayload): Promise { + if (!this.enabled) { + throw new Error("Cannot create user, auth not enabled"); + } + const strategy = "password"; const pw = this.authenticator.strategy(strategy) as PasswordStrategy; const strategy_value = await pw.hash(password); diff --git a/app/src/auth/middlewares.ts b/app/src/auth/middlewares.ts index d85d0d8..927d6c6 100644 --- a/app/src/auth/middlewares.ts +++ b/app/src/auth/middlewares.ts @@ -21,12 +21,16 @@ async function resolveAuth(app: ServerEnv["Variables"]["app"], c: Context(async (c, next) => { - if (!shouldSkipAuth) { + if (!shouldSkipAuth(c.req.raw)) { // make sure to only register once if (c.get("auth_registered")) { return;