From c6cbf1f0727bd1d288600e5fc63eafa317f730b4 Mon Sep 17 00:00:00 2001 From: Evert Pot Date: Thu, 5 Dec 2024 23:58:33 -0500 Subject: [PATCH] Fix 500 error when requesting a user-access-token --- changelog.md | 6 ++++++ src/log/service.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 9deaa1c8..49fcfc62 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,12 @@ Changelog ========= +0.27.1 (????-??-??) +------------------- + +* Fix HTTP/500 error when requesting a developer access token. + + 0.27.0 (2024-12-05) ------------------- diff --git a/src/log/service.ts b/src/log/service.ts index e175e871..7e91c293 100644 --- a/src/log/service.ts +++ b/src/log/service.ts @@ -6,10 +6,17 @@ import geoip from 'geoip-lite'; import { UserLogRecord } from 'knex/types/tables.js'; export function getLoggerFromContext(ctx: Context, principal?: Principal|number): UserEventLogger { + + let principalId; + if (typeof principal === 'number') { + principalId = principal; + } else { + principalId = principal?.id ?? ctx.session.user?.id; + } return (et: EventType) => addLogEntry( et, ctx.ip() ?? '', - principal ?? ctx.session.user?.id, + principalId, ctx.request.headers.get('User-Agent') ); }