Uecko_ERP/apps/server/archive/contexts/auth/application/refresh-token/refresh-token.use-case.ts

25 lines
794 B
TypeScript
Raw Normal View History

2025-05-02 21:43:51 +00:00
import { ITransactionManager } from "@/core/common/infrastructure/database";
import { Token } from "../../domain";
import { IAuthService } from "../../domain/services";
2025-02-15 21:30:12 +00:00
export class RefreshTokenUseCase {
constructor(
private readonly authService: IAuthService,
private readonly transactionManager: ITransactionManager
) {}
public async execute(token: Token) {
return await this.transactionManager.complete(async (transaction) => {
2025-02-16 19:30:20 +00:00
const payloadData = this.authService.verifyRefreshToken(token);
2025-02-15 21:30:12 +00:00
2025-02-16 19:30:20 +00:00
/*if (!payload || !payload.email || !payload.user_id || !payload.tab_id || !payload.roles) {
return Result.fail(new Error("Invalid input data"));
}*/
2025-02-15 21:30:12 +00:00
return this.authService.generateRefreshToken({
2025-02-16 19:30:20 +00:00
...payloadData,
2025-02-15 21:30:12 +00:00
});
});
}
}