Delete proxy-auth.ts, types/index.ts, staff-user.ts+test, local-imports.ts+test (only used by their own tests). Remove unused foundation exports: sanitizeFilename, canonicalizeFormValue, canonicalizeFormData, ConflictError, getRequestStore, getClientIp, elapsed. Remove stale TODO comments from rank-authority.ts and notice.ts. Fix biome lint warnings in catalog-repair.ts.
27 lines
752 B
TypeScript
27 lines
752 B
TypeScript
import type { AuthorizationActor } from "@/lib/admin/authorization-policy";
|
|
|
|
export interface RankAuthorityDb {
|
|
user: {
|
|
findUnique(args: {
|
|
where: { id: number };
|
|
select: { id: true; username: true; rank: true };
|
|
}): Promise<{ id: number; username: string; rank: number } | null>;
|
|
};
|
|
highestRank(): Promise<number | null>;
|
|
}
|
|
|
|
export async function resolveAuthorizationState(
|
|
userId: number,
|
|
db: RankAuthorityDb,
|
|
): Promise<{ actor: AuthorizationActor; highestRank: number | null } | null> {
|
|
const [user, highestRank] = await Promise.all([
|
|
db.user.findUnique({
|
|
where: { id: userId },
|
|
select: { id: true, username: true, rank: true },
|
|
}),
|
|
db.highestRank(),
|
|
]);
|
|
if (!user) return null;
|
|
return { actor: user, highestRank };
|
|
}
|