"activate user admin"

This commit is contained in:
magdo
2025-10-27 20:35:07 +01:00
parent 04954cec4a
commit 99ed8fea54
6 changed files with 93 additions and 22 deletions
@@ -39,6 +39,7 @@ import { ProcessOrgAuthCallbackCommandHandler } from '../Organization/commands/P
import { CreateContactCommandHandler } from '../Contact/commands/CreateContactCommandHandler';
import { UpdateContactCommandHandler } from '../Contact/commands/UpdateContactCommandHandler';
import { DeleteContactCommandHandler } from '../Contact/commands/DeleteContactCommandHandler';
import { ActivateUserCommandHandler } from '../User/commands/ActivateUserCommandHandler';
// Query Handlers
import { GetUserByIdQueryHandler } from '../User/queries/GetUserByIdQueryHandler';
@@ -121,6 +122,7 @@ export class DIContainer {
private _updateContactCommandHandler: UpdateContactCommandHandler | null = null;
private _deleteContactCommandHandler: DeleteContactCommandHandler | null = null;
private _generateBoardCommandHandler: GenerateBoardCommandHandler | null = null;
private _activateUserCommandHandler: ActivateUserCommandHandler | null = null;
// Query Handlers
private _getUserByIdQueryHandler: GetUserByIdQueryHandler | null = null;
@@ -306,6 +308,13 @@ export class DIContainer {
return this._deactivateUserCommandHandler;
}
public get activateUserCommandHandler(): ActivateUserCommandHandler {
if (!this._activateUserCommandHandler) {
this._activateUserCommandHandler = new ActivateUserCommandHandler(this.userRepository);
}
return this._activateUserCommandHandler;
}
public get deleteUserCommandHandler(): DeleteUserCommandHandler {
if (!this._deleteUserCommandHandler) {
this._deleteUserCommandHandler = new DeleteUserCommandHandler(this.userRepository);
@@ -0,0 +1,3 @@
export interface ActivateUserCommand {
id: string;
}
@@ -0,0 +1,12 @@
import { IUserRepository } from '../../../Domain/IRepository/IUserRepository';
import { ActivateUserCommand } from './ActivateUserCommand';
export class ActivateUserCommandHandler {
constructor(private readonly userRepo: IUserRepository) {}
async execute(cmd: ActivateUserCommand): Promise<boolean> {
await this.userRepo.activate(cmd.id);
return true;
}
}