Skip to content

Commit

Permalink
fix: limit the characters for name on user (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan authored Feb 28, 2024
1 parent ce9752b commit ea90147
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/core/src/auth/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,17 @@ export class UserService {
return await this.userRepository.save(newUser)
}

containsInvalidCharacters(value: string): boolean {
return value.includes(".") || value.includes("http")
}

public async createPublicUser(dto: UserCreateDto, sendWelcomeEmail = false) {
if (
this.containsInvalidCharacters(dto.firstName) ||
this.containsInvalidCharacters(dto.lastName)
) {
throw new HttpException("Forbidden", HttpStatus.FORBIDDEN)
}
const newUser = await this._createUser({
...dto,
passwordHash: await this.passwordService.passwordToHash(dto.password),
Expand Down

0 comments on commit ea90147

Please sign in to comment.