Skip to content

Commit

Permalink
fix: add character validation on user creation (#1653)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan authored Feb 28, 2024
1 parent bad8bae commit 8e7ed3a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/core/src/auth/services/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BadRequestException,
HttpException,
HttpStatus,
Injectable,
NotFoundException,
Scope,
Expand Down Expand Up @@ -409,11 +410,21 @@ export class UserService {
return await this.userRepository.save(newUser)
}

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

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

0 comments on commit 8e7ed3a

Please sign in to comment.