diff --git a/src/routes/api/domains/ls.ts b/src/routes/api/domains/ls.ts index 34bc2e29..9300130f 100644 --- a/src/routes/api/domains/ls.ts +++ b/src/routes/api/domains/ls.ts @@ -3,6 +3,7 @@ import { generateSunflake } from 'sunflake'; import { DB } from '../../../database'; import { useAuth } from '../../../util/http/useAuth'; +import { log } from '../../../util/logging'; import { Poof } from '../../../util/sentry/sentryHandle'; export const generateSnowflake = generateSunflake(); @@ -18,7 +19,11 @@ export const DomainLsRoute: FastifyPluginAsync = async (router, options) => { const authData = (await useAuth(_request, reply)) as Poof | string; if (determineIfAuth(authData)) { - return reply.status(authData.status).send(); + reply.status(authData.status || 500); + reply.send(); + log.ok(...authData.logMessages); + + return; } reply.send( diff --git a/src/util/http/useAuth.ts b/src/util/http/useAuth.ts index acd17226..7fbd1a68 100644 --- a/src/util/http/useAuth.ts +++ b/src/util/http/useAuth.ts @@ -26,6 +26,8 @@ export const useAuth: ( auth = auth.slice('Bearer '.length); } + console.log(auth); + const decoded = decode(auth) as { address: string; user_id: string }; if (!decoded) @@ -43,11 +45,16 @@ export const useAuth: ( logMessages: ['Key "user_id" was missing from payload'], }; - if (verify(auth, process.env.SIGNAL_MASTER)) + console.log(process.env.SIGNAL_MASTER); + + try { + verify(auth, process.env.SIGNAL_MASTER); + } catch { return { status: 403, logMessages: ['Invalid signature on payload'], }; + } const owner = await DB.selectOneFrom('owners', ['user_id'], { address: decoded.address,