mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-09-27 03:14:48 +02:00
Review changes
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user