From b3b94bacca346f54da766276999b99f494c53eec Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 15 Dec 2020 13:23:25 +0100 Subject: [PATCH] Fix register socket --- sockets/register.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sockets/register.js b/sockets/register.js index eaa8381..3a931b4 100644 --- a/sockets/register.js +++ b/sockets/register.js @@ -8,14 +8,17 @@ module.exports = socket => { else if ((!data.email.endsWith("@univ-lyon1.fr")) && (!data.email.endsWith("@etu.univ-lyon1.fr"))) socket.emit("register", {error: {message: "invalid_email"}}); else { - let user = await models.User.create({ - email: data.email, - firstName: data.firstName, - lastName: data.lastName, - passwordHash: data.password - }); - - await emailCheck(socket, user, null); + try { + let user = await models.User.create({ + email: data.email, + firstName: data.firstName, + lastName: data.lastName, + passwordHash: data.password + }); + await emailCheck(socket, user, null); + } catch (Exception) { + socket.emit("register", {error: {message: "invalid_email"}}) + } } } -}; \ No newline at end of file +};