Review changes

This commit is contained in:
Karl Ludwig Weise
2026-08-31 09:52:29 +02:00
parent 7e93d686f2
commit 56dfe32ea5
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -169,10 +169,10 @@ export class ScheduleService {
let staffKeyShares: Record<string, string> = {};
// Tunnel keys are wrapped per passkey; scope the lookup to the passkey the user most
// recently authenticated with (same definition getClientTunnels / key-shard use).
const recentPasskey = request.staffUserId
const currentPasskey = request.staffUserId
? await WebAuthnService.getCurrentPasskey(request.staffUserId, passkeyId)
: null;
if (request.staffUserId && recentPasskey && appointments.length > 0) {
if (request.staffUserId && currentPasskey && appointments.length > 0) {
const tunnelIds = [...new Set(appointments.map((apt) => apt.tunnelId))];
const keyShares = await db
.select()
@@ -180,7 +180,7 @@ export class ScheduleService {
.where(
and(
eq(tenantSchema.clientTunnelStaffKeyShare.userId, request.staffUserId),
eq(tenantSchema.clientTunnelStaffKeyShare.passkeyId, recentPasskey.id),
eq(tenantSchema.clientTunnelStaffKeyShare.passkeyId, currentPasskey.id),
inArray(tenantSchema.clientTunnelStaffKeyShare.tunnelId, tunnelIds),
),
);
@@ -148,12 +148,12 @@ export const GET: RequestHandler = async ({ params, locals }) => {
try {
// Get the most recently used passkey for this authenticated user
const recentPasskey = await WebAuthnService.getCurrentPasskey(
const currentPasskey = await WebAuthnService.getCurrentPasskey(
locals.user.id,
locals.user?.passkeyId,
);
if (!recentPasskey) {
if (!currentPasskey) {
log.warn("No passkey found for authenticated user - security violation", {
tenantId,
staffId,
@@ -163,12 +163,12 @@ export const GET: RequestHandler = async ({ params, locals }) => {
throw new AuthorizationError("No valid passkey found for authenticated user");
}
passkeyId = recentPasskey.id;
passkeyId = currentPasskey.id;
log.debug("Using authenticated user's most recent passkey", {
tenantId,
staffId,
passkeyId,
lastUsedAt: recentPasskey.lastUsedAt,
lastUsedAt: currentPasskey.lastUsedAt,
});
} catch (error) {
if (error instanceof AuthorizationError) {