58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import { BaseCustomManager } from 'src/core/modules/domain/usecase/managers/base-custom.manager';
|
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
|
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
|
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
|
|
import { LogUserType } from 'src/core/helpers/constant';
|
|
import { LogUserLoginEvent } from 'src/modules/configuration/log/domain/entities/log-user-login.event';
|
|
|
|
export class LogoutManager extends BaseCustomManager<UserEntity> {
|
|
async validateProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
async beforeProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
async process(): Promise<void> {
|
|
await this.dataService.update(
|
|
this.queryRunner,
|
|
this.entityTarget,
|
|
{ id: this.user.id },
|
|
{
|
|
refresh_token: null,
|
|
},
|
|
);
|
|
|
|
await this.publishEvents();
|
|
return;
|
|
}
|
|
|
|
async afterProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
getResult() {
|
|
return `Success Logout user`;
|
|
}
|
|
|
|
get entityTarget(): any {
|
|
return UserModel;
|
|
}
|
|
|
|
get eventTopics(): EventTopics[] {
|
|
return [
|
|
{
|
|
topic: LogUserLoginEvent,
|
|
data: {
|
|
type: LogUserType.logout,
|
|
role: this.user.role,
|
|
user_id: this.user.id,
|
|
username: this.user.name,
|
|
created_at: new Date().getTime(),
|
|
},
|
|
},
|
|
];
|
|
}
|
|
}
|