Refactor email sending + remove email verification if mail sending is not set up

This commit is contained in:
Madeline
2023-08-12 15:36:29 +10:00
parent ecb227105a
commit d18584f8e9
7 changed files with 174 additions and 281 deletions
+3 -5
View File
@@ -18,14 +18,13 @@
import { getIpAdress, route, verifyCaptcha } from "@spacebar/api";
import {
adjustEmail,
Config,
FieldErrors,
generateToken,
generateWebAuthnTicket,
LoginSchema,
User,
WebAuthn,
generateToken,
generateWebAuthnTicket,
} from "@spacebar/util";
import bcrypt from "bcrypt";
import crypto from "crypto";
@@ -50,7 +49,6 @@ router.post(
async (req: Request, res: Response) => {
const { login, password, captcha_key, undelete } =
req.body as LoginSchema;
const email = adjustEmail(login);
const config = Config.get();
@@ -76,7 +74,7 @@ router.post(
}
const user = await User.findOneOrFail({
where: [{ phone: login }, { email: email }],
where: [{ phone: login }, { email: login }],
select: [
"data",
"id",
+1 -4
View File
@@ -30,7 +30,6 @@ import {
RegisterSchema,
User,
ValidRegistrationToken,
adjustEmail,
generateToken,
} from "@spacebar/util";
import bcrypt from "bcrypt";
@@ -76,9 +75,6 @@ router.post(
}
}
// email will be slightly modified version of the user supplied email -> e.g. protection against GMail Trick
const email = adjustEmail(body.email);
// check if registration is allowed
if (!regTokenUsed && !register.allowNewRegistration) {
throw FieldErrors({
@@ -161,6 +157,7 @@ router.post(
// TODO: gift_code_sku_id?
// TODO: check password strength
const email = body.email;
if (email) {
// replace all dots and chars after +, if its a gmail.com email
if (!email) {
-2
View File
@@ -18,7 +18,6 @@
import { route } from "@spacebar/api";
import {
adjustEmail,
Config,
emitEvent,
FieldErrors,
@@ -111,7 +110,6 @@ router.patch(
}
if (body.email) {
body.email = adjustEmail(body.email);
if (!body.email && Config.get().register.email.required)
throw FieldErrors({
email: {