refactor use cases
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { IdentityProviderPort, AuthProvider, StartAuthCommand } from '../ports/IdentityProviderPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { UseCaseOutputPort, Logger } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
|
||||
export type StartAuthInput = {
|
||||
provider: AuthProvider;
|
||||
@@ -21,10 +21,9 @@ export class StartAuthUseCase {
|
||||
constructor(
|
||||
private readonly provider: IdentityProviderPort,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<StartAuthResult>,
|
||||
) {}
|
||||
|
||||
async execute(input: StartAuthInput): Promise<Result<void, StartAuthApplicationError>> {
|
||||
async execute(input: StartAuthInput): Promise<Result<StartAuthResult, StartAuthApplicationError>> {
|
||||
try {
|
||||
const command: StartAuthCommand = input.returnTo
|
||||
? {
|
||||
@@ -38,9 +37,8 @@ export class StartAuthUseCase {
|
||||
const { redirectUrl, state } = await this.provider.startAuth(command);
|
||||
|
||||
const result: StartAuthResult = { redirectUrl, state };
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
const message =
|
||||
error instanceof Error && error.message
|
||||
|
||||
Reference in New Issue
Block a user