wip: checkpoint host working tree
Login-page gate, notification outbox dispatcher and cron, assignment proposals/responses, coverage and training-guide updates, plus the generated training PDFs. Checkpointed from the host before merging the invite-link fix.
This commit is contained in:
+21
-1
@@ -9,7 +9,7 @@
|
||||
* patch that omits a field (say, the phone) never nulls it out.
|
||||
*/
|
||||
|
||||
import { and, asc, eq, isNull, ne, or, sql } from "drizzle-orm";
|
||||
import { and, asc, eq, isNotNull, isNull, ne, or, sql } from "drizzle-orm";
|
||||
import { db } from "@/db";
|
||||
import { assignments, userSkills, users } from "@/db/schema";
|
||||
import type { SystemRole } from "@/auth/roles";
|
||||
@@ -197,6 +197,26 @@ export async function hasAssignmentHistory(userId: string): Promise<boolean> {
|
||||
return Boolean(row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether any admin has real credentials. Once this is true, public
|
||||
* magic-link sign-in is closed: anyone who knew an admin's email could
|
||||
* otherwise mint a full admin session from the login page. New-account and
|
||||
* recovery links remain available to signed-in admins.
|
||||
*/
|
||||
export async function hasPasswordProtectedAdmin(): Promise<boolean> {
|
||||
const [row] = await db
|
||||
.select({ id: users.id })
|
||||
.from(users)
|
||||
.where(
|
||||
and(
|
||||
eq(users.systemRole, "admin"),
|
||||
isNotNull(users.passwordHash),
|
||||
),
|
||||
)
|
||||
.limit(1);
|
||||
return Boolean(row);
|
||||
}
|
||||
|
||||
/** Active admins who could still sign in, excluding the person being changed. */
|
||||
export async function countOtherActiveAdmins(excludeUserId: string): Promise<number> {
|
||||
const [row] = await db
|
||||
|
||||
Reference in New Issue
Block a user