change email validation to regex only

This commit is contained in:
Julian Krauser 2025-05-01 17:36:48 +02:00
parent 753cfdd5da
commit 0ea780dd51
4 changed files with 37 additions and 52 deletions

View file

@ -1,7 +1,7 @@
import { Transporter, createTransport, TransportOptions } from "nodemailer";
import { Attachment } from "nodemailer/lib/mailer";
import SettingHelper from "./settingsHelper";
import emailCheck from "email-check";
import validator from "validator";
export default abstract class MailHelper {
private static transporter: Transporter;
@ -45,7 +45,8 @@ export default abstract class MailHelper {
.then(() => {
return true;
})
.catch(() => {
.catch((err) => {
console.log(err);
return false;
})
.finally(() => {
@ -56,13 +57,14 @@ export default abstract class MailHelper {
}
static async checkMail(mail: string): Promise<boolean> {
return await emailCheck(mail)
.then((res) => {
return res;
})
.catch((err) => {
return false;
});
return validator.isEmail(mail);
// return await emailCheck(mail)
// .then((res) => {
// return res;
// })
// .catch((err) => {
// return false;
// });
}
static initialize() {

View file

@ -56,17 +56,12 @@ export default abstract class SettingHelper {
return rawValue as unknown as SettingValueMapping[K];
}
let processedValue = rawValue;
if (typeof settingType.type === "string" && settingType.type.includes("/crypt")) {
processedValue = CodingHelper.decrypt(APPLICATION_SECRET, processedValue);
}
const baseType =
typeof settingType.type === "string"
? (settingType.type.split("/")[0] as SettingTypeAtom)
: (settingType.type as SettingTypeAtom);
return this.converters[baseType].fromString(processedValue) as unknown as SettingValueMapping[K];
return this.converters[baseType].fromString(rawValue) as unknown as SettingValueMapping[K];
}
/**