56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { FlowExecCtx } from "@/core/flow.execution.context";
|
|
import { AccountRepository } from "./account.repository";
|
|
import { UserRepository } from "./repository";
|
|
import { db } from "@pkg/db";
|
|
|
|
export class UserController {
|
|
constructor(
|
|
private userRepository: UserRepository,
|
|
private accountRepo: AccountRepository,
|
|
) {}
|
|
|
|
getUserInfo(fctx: FlowExecCtx, userId: string) {
|
|
return this.userRepository.getUserInfo(fctx, userId);
|
|
}
|
|
|
|
ensureAccountExists(fctx: FlowExecCtx, userId: string) {
|
|
return this.accountRepo.ensureAccountExists(fctx, userId);
|
|
}
|
|
|
|
isUsernameAvailable(fctx: FlowExecCtx, username: string) {
|
|
return this.userRepository.isUsernameAvailable(fctx, username);
|
|
}
|
|
|
|
updateLastVerified2FaAtToNow(fctx: FlowExecCtx, userId: string) {
|
|
return this.userRepository.updateLastVerified2FaAtToNow(fctx, userId);
|
|
}
|
|
|
|
banUser(
|
|
fctx: FlowExecCtx,
|
|
userId: string,
|
|
reason: string,
|
|
banExpiresAt: Date,
|
|
) {
|
|
return this.userRepository.banUser(fctx, userId, reason, banExpiresAt);
|
|
}
|
|
|
|
isUserBanned(fctx: FlowExecCtx, userId: string) {
|
|
return this.userRepository.isUserBanned(fctx, userId);
|
|
}
|
|
|
|
getBanInfo(fctx: FlowExecCtx, userId: string) {
|
|
return this.userRepository.getBanInfo(fctx, userId);
|
|
}
|
|
|
|
rotatePassword(fctx: FlowExecCtx, userId: string, password: string) {
|
|
return this.accountRepo.rotatePassword(fctx, userId, password);
|
|
}
|
|
}
|
|
|
|
export function getUserController(): UserController {
|
|
return new UserController(
|
|
new UserRepository(db),
|
|
new AccountRepository(db),
|
|
);
|
|
}
|