error in sending back messages on e-mail signup

This commit is contained in:
adueck 2023-12-17 11:19:05 +04:00
parent f84c179e37
commit 51e22a4611
2 changed files with 3 additions and 5 deletions

View File

@ -157,14 +157,12 @@ export async function createNewUser(
lastLogin: now, lastLogin: now,
lastActive: now, lastActive: now,
}; };
console.log("SENDING VERIFICATION EMAIL FROM SIGNUP");
await sendVerificationEmail({ await sendVerificationEmail({
name: input.name, name: input.name,
uid: userId, uid: userId,
email: input.email || "", email: input.email || "",
token: email.token, token: email.token,
}); });
console.log("GOT THROUGH AFTER VERIFICATION");
const user = await insertLingdocsUser(newUser); const user = await insertLingdocsUser(newUser);
return user; return user;
} }

View File

@ -176,7 +176,8 @@ const authRouter = (passport: PassportStatic) => {
try { try {
const { email, password, name } = req.body; const { email, password, name } = req.body;
const existingUser = await getLingdocsUser("email", email); const existingUser = await getLingdocsUser("email", email);
if (existingUser) return res.send("User Already Exists"); if (existingUser)
return res.send({ ok: false, message: "User Already Exists" });
try { try {
const user = await createNewUser({ const user = await createNewUser({
strategy: "local", strategy: "local",
@ -190,8 +191,7 @@ const authRouter = (passport: PassportStatic) => {
}); });
} catch (e) { } catch (e) {
console.error(e); console.error(e);
console.error("EMAIL DIDN'T WORK 2"); return res.send({ ok: false, message: "Invalid E-mail" });
return res.send("Invalid E-mail");
} }
} catch (e) { } catch (e) {
next(e); next(e);