We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f1f3a52 commit 2679d92Copy full SHA for 2679d92
1 file changed
src/controllers/UserController.js
@@ -9,6 +9,12 @@ class UserController {
9
10
async create(request, response) {
11
const { name, email } = request.body;
12
+ const result = await User.find({ where: { email } });
13
+ const userFoundByEmail = result[0];
14
+
15
+ if (userFoundByEmail)
16
+ return response.status(400).json({ error: 'Email already exists!' });
17
18
const user = await User.create({ name, email });
19
20
return response.status(201).json(user);
0 commit comments