Skip to content

Commit

Permalink
Modify SignupPostController to use identity provider #181
Browse files Browse the repository at this point in the history
  • Loading branch information
mapeveri committed Jan 18, 2025
1 parent 662afc3 commit aa36f7b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/account/app/controllers/v1/auth/signupPostController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import { ApiBadRequestResponse, ApiInternalServerErrorResponse, ApiTags } from '
import SignupPostDto from '@src/account/app/controllers/v1/auth/signupPostDto';
import { COMMAND_BUS, CommandBus } from '@src/shared/domain/bus/commandBus/commandBus';
import SignUpUserCommand from '@src/account/application/auth/command/signUpUserCommand';
import { Uuid } from '@src/shared/domain/valueObjects/uuid';
import { IDENTITY_PROVIDER, IdentityProvider } from '@src/shared/domain/services/IdentityProvider';

@ApiTags('Auth')
@Controller()
export default class SignupPostController {
public constructor(@Inject(COMMAND_BUS) private commandBus: CommandBus) {}
public constructor(
@Inject(COMMAND_BUS) private commandBus: CommandBus,
@Inject(IDENTITY_PROVIDER) private identityProvider: IdentityProvider,
) {}

@Post('auth/signup')
@HttpCode(201)
@ApiBadRequestResponse({ description: 'Bad Request.' })
@ApiInternalServerErrorResponse({ description: 'Internal Server Error.' })
async run(@Body() payload: SignupPostDto): Promise<void> {
const id = Uuid.fromString(payload.email).toString();
const id = this.identityProvider.generateFromValue(payload.email);

await this.commandBus.dispatch(
new SignUpUserCommand(id, payload.name, payload.email, payload.token, payload.provider, payload.photo),
Expand Down

0 comments on commit aa36f7b

Please sign in to comment.