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,
lastActive: now,
};
console.log("SENDING VERIFICATION EMAIL FROM SIGNUP");
await sendVerificationEmail({
name: input.name,
uid: userId,
email: input.email || "",
token: email.token,
});
console.log("GOT THROUGH AFTER VERIFICATION");
const user = await insertLingdocsUser(newUser);
return user;
}

View File

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