add resource whitelist auth method

This commit is contained in:
Milo Schwartz 2024-12-16 22:40:42 -05:00
parent 998fab6d0a
commit 207a7b8a39
No known key found for this signature in database
20 changed files with 970 additions and 739 deletions

View file

@ -16,10 +16,10 @@ export async function createResourceSession(opts: {
resourceId: number;
passwordId?: number;
pincodeId?: number;
whitelistId: number;
whitelistId?: number;
usedOtp?: boolean;
}): Promise<ResourceSession> {
if (!opts.passwordId && !opts.pincodeId) {
if (!opts.passwordId && !opts.pincodeId && !opts.whitelistId) {
throw new Error(
"At least one of passwordId or pincodeId must be provided"
);
@ -35,8 +35,7 @@ export async function createResourceSession(opts: {
resourceId: opts.resourceId,
passwordId: opts.passwordId || null,
pincodeId: opts.pincodeId || null,
whitelistId: opts.whitelistId,
usedOtp: opts.usedOtp || false
whitelistId: opts.whitelistId || null
};
await db.insert(resourceSessions).values(session);
@ -129,7 +128,6 @@ export async function invalidateAllSessions(
eq(resourceSessions.whitelistId, method.whitelistId)
)
);
}
if (!method?.passwordId && !method?.pincodeId && !method?.whitelistId) {
await db