Add email field and add it to register logic
This commit is contained in:
@ -33,16 +33,22 @@ class UserService {
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
async register(username: string, password: string): Promise<boolean | User> {
|
||||
async register(username: string, email: string, password: string): Promise<boolean | User> {
|
||||
const user = await UserRepository.getByUsername(username)
|
||||
if (user) {
|
||||
return false
|
||||
}
|
||||
|
||||
const userByEmail = await UserRepository.getByEmail(email)
|
||||
if (userByEmail) {
|
||||
return false
|
||||
}
|
||||
|
||||
const hashedPassword = await bcrypt.hash(password, 10)
|
||||
return prisma.user.create({
|
||||
data: {
|
||||
username,
|
||||
email,
|
||||
password: hashedPassword
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user