Add email field and add it to register logic
This commit is contained in:
@ -40,16 +40,16 @@ async function addHttpRoutes(app: Application) {
|
||||
* @param res
|
||||
*/
|
||||
app.post('/register', async (req: Request, res: Response) => {
|
||||
const { username, password } = req.body
|
||||
const { username, email, password } = req.body
|
||||
|
||||
try {
|
||||
registerAccountSchema.parse({ username, password })
|
||||
registerAccountSchema.parse({ username, email, password })
|
||||
} catch (error: any) {
|
||||
return res.status(400).json({ message: error.errors[0]?.message })
|
||||
}
|
||||
|
||||
const userService = new UserService()
|
||||
const user = await userService.register(username, password)
|
||||
const user = await userService.register(username, email, password)
|
||||
|
||||
if (user) {
|
||||
return res.status(200).json({ message: 'User registered' })
|
||||
|
Reference in New Issue
Block a user