Harden user management integration
This commit is contained in:
parent
73579d1e79
commit
847f4e9493
18 changed files with 394 additions and 111 deletions
40
src/domain/ports/user.store.ts
Normal file
40
src/domain/ports/user.store.ts
Normal 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>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue