feat: complete admin invite and user creation and recovery flows
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user