feat: complete admin invite and user creation and recovery flows

This commit is contained in:
Zoe
2026-10-08 14:24:47 -05:00
parent 61f9bb74b4
commit b6f4d85ed7
23 changed files with 4430 additions and 110 deletions
+5 -2
View File
@@ -1,5 +1,5 @@
import { asc, eq, max } from 'drizzle-orm';
import { sessions, users } from '~~/drizzle/schema';
import { asc, eq, max, sql } from 'drizzle-orm';
import { accounts, sessions, users } from '~~/drizzle/schema';
import { db } from '~~/server/lib/db';
/**
@@ -24,6 +24,9 @@ export default defineEventHandler(async (event) => {
// sessions are touched as they are used, the newest one is the
// closest thing there is to a last seen time
lastActiveAt: max(sessions.updatedAt),
// no password yet: created by an admin and still waiting for its
// owner to open the setup link
pending: sql<boolean>`not exists (select 1 from ${accounts} where ${accounts.userId} = ${users.id} and ${accounts.providerId} = 'credential')`,
})
.from(users)
.leftJoin(sessions, eq(sessions.userId, users.id))