Skip to content

Commit c6cbf1f

Browse files
committed
Fix 500 error when requesting a user-access-token
1 parent 9d5ffbd commit c6cbf1f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Diff for: changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
0.27.1 (????-??-??)
5+
-------------------
6+
7+
* Fix HTTP/500 error when requesting a developer access token.
8+
9+
410
0.27.0 (2024-12-05)
511
-------------------
612

Diff for: src/log/service.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ import geoip from 'geoip-lite';
66
import { UserLogRecord } from 'knex/types/tables.js';
77

88
export function getLoggerFromContext(ctx: Context, principal?: Principal|number): UserEventLogger {
9+
10+
let principalId;
11+
if (typeof principal === 'number') {
12+
principalId = principal;
13+
} else {
14+
principalId = principal?.id ?? ctx.session.user?.id;
15+
}
916
return (et: EventType) => addLogEntry(
1017
et,
1118
ctx.ip() ?? '',
12-
principal ?? ctx.session.user?.id,
19+
principalId,
1320
ctx.request.headers.get('User-Agent')
1421
);
1522
}

0 commit comments

Comments
 (0)