Harden user management integration

This commit is contained in:
Julian Appel 2026-09-28 22:42:03 +02:00
parent 73579d1e79
commit 847f4e9493
18 changed files with 394 additions and 111 deletions

View file

@ -0,0 +1,40 @@
import type { UserRole } from "../../shared/constants/user-roles.js";
export interface UserAccount {
id: string;
username: string;
passwordHash: string;
name: string;
role: UserRole;
active: boolean;
mustChangePassword: boolean;
createdAt: Date;
updatedAt: Date;
}
export interface CreateUserAccount {
username: string;
name: string;
role: UserRole;
passwordHash: string;
}
export class UsernameAlreadyExistsStoreError extends Error {}
export class LastActiveAdminStoreError extends Error {}
export interface UserStore {
list(): Promise<UserAccount[]>;
count(): Promise<number>;
findById(userId: string): Promise<UserAccount | null>;
findByUsername(username: string): Promise<UserAccount | null>;
create(input: CreateUserAccount): Promise<UserAccount | null>;
updateRoleAndActive(
userId: string,
patch: { role?: UserRole; active?: boolean }
): Promise<UserAccount | null>;
setPassword(
userId: string,
passwordHash: string,
mustChangePassword: boolean
): Promise<UserAccount | null>;
}