diff --git a/src/daemon/run.ts b/src/daemon/run.ts index eab1a0a..813a700 100644 --- a/src/daemon/run.ts +++ b/src/daemon/run.ts @@ -174,10 +174,13 @@ class Daemon { async startWebAuth() { if (!this.config.authPort) return; + const prefix = new URL(this.config.baseUrl as string).pathname.replace(/\/+$/, ''); + this.fastify.register(FastifyView, { engine: { handlebars: Handlebars - } + }, + prefix }); this.fastify.listen({ port: this.config.authPort }); diff --git a/src/daemon/web/authorize.ts b/src/daemon/web/authorize.ts index 1d2f438..e54fa2a 100644 --- a/src/daemon/web/authorize.ts +++ b/src/daemon/web/authorize.ts @@ -49,8 +49,6 @@ export async function authorizeRequestWebHandler(request, reply) { const record = await getAndValidateStateOfRequest(request); const url = new URL(request.url, `http://${request.headers.host}`); const callbackUrl = url.searchParams.get("callbackUrl"); - console.log(request) - const baseUrl = new URL(request.originalUrl).pathname.replace(/\/+$/, ''); const method = record.method; let nip05: string | undefined; @@ -61,7 +59,7 @@ export async function authorizeRequestWebHandler(request, reply) { const [ username, domain, email ] = JSON.parse(record.params!); nip05 = `${username}@${domain}`; - return reply.view("/templates/createAccount.handlebar", { baseUrl, record, email, username, domain, nip05, callbackUrl }); + return reply.view("/templates/createAccount.handlebar", { record, email, username, domain, nip05, callbackUrl }); } else { const authorized = validateAuthCookie(request); return reply.view("/templates/authorizeRequest.handlebar", { record, callbackUrl, authorized }); @@ -165,8 +163,6 @@ export async function processRegistrationWebHandler(request, reply) { try { const record = await getAndValidateStateOfRequest(request); const body = request.body; - console.log(request) - const baseUrl = new URL(request.originalUrl).pathname.replace(/\/+$/, ''); // we serialize the payload again and store it // along with the allowed flag @@ -183,7 +179,7 @@ export async function processRegistrationWebHandler(request, reply) { const [ username, domain, email ] = JSON.parse(record.params!); const nip05 = `${username}@${domain}`; - return reply.view("/templates/createAccount.handlebar", { baseUrl, record, email, username, domain, nip05, error: e.message}); + return reply.view("/templates/createAccount.handlebar", { record, email, username, domain, nip05, error: e.message}); } await prisma.request.update({ diff --git a/templates/createAccount.handlebar b/templates/createAccount.handlebar index fe578e1..34bd312 100644 --- a/templates/createAccount.handlebar +++ b/templates/createAccount.handlebar @@ -87,7 +87,7 @@
{{#if error}} diff --git a/templates/login.handlebar b/templates/login.handlebar index 446e2d4..5f97a4b 100644 --- a/templates/login.handlebar +++ b/templates/login.handlebar @@ -52,7 +52,7 @@