(email: string, password: string, name?: string)
| 16 | ) {} |
| 17 | |
| 18 | async create(email: string, password: string, name?: string): Promise<User> { |
| 19 | const existingUser = await this.findByEmail(email); |
| 20 | if (existingUser) { |
| 21 | throw new ConflictException('User with this email already exists'); |
| 22 | } |
| 23 | |
| 24 | // Use stronger salt rounds (12 instead of 10) for better security |
| 25 | const saltRounds = parseInt(process.env.BCRYPT_SALT_ROUNDS || '12'); |
| 26 | const hashedPassword = await bcrypt.hash(password, saltRounds); |
| 27 | const user = this.usersRepository.create({ |
| 28 | email, |
| 29 | password: hashedPassword, |
| 30 | name, |
| 31 | }); |
| 32 | |
| 33 | return this.usersRepository.save(user); |
| 34 | } |
| 35 | |
| 36 | async findAll(): Promise<User[]> { |
| 37 | return this.usersRepository.find(); |
no test coverage detected