Add adjustEmail call to setEmail
This commit is contained in:
parent
b8aee9b217
commit
b132f2d384
@ -3,7 +3,7 @@ import { BaseClass } from "./BaseClass";
|
||||
import { BitField } from "../util/BitField";
|
||||
import { Relationship } from "./Relationship";
|
||||
import { ConnectedAccount } from "./ConnectedAccount";
|
||||
import { Config, FieldErrors, Snowflake, trimSpecial, BannedWords } from "..";
|
||||
import { Config, FieldErrors, Snowflake, trimSpecial, BannedWords, adjustEmail } from "..";
|
||||
import { Member, Session } from ".";
|
||||
|
||||
export enum PublicUserEnum {
|
||||
@ -72,7 +72,7 @@ export class User extends BaseClass {
|
||||
if (val.length > 4) throw new Error("invalid discriminator");
|
||||
if (isNaN(number)) throw new Error("invalid discriminator");
|
||||
if (number <= 0 || number >= 10000) throw new Error("discriminator must be between 1 and 9999");
|
||||
val = Number(val).toString()
|
||||
val = Number(val).toString();
|
||||
this.discriminator = val.toString().padStart(4, "0");
|
||||
}
|
||||
|
||||
@ -139,10 +139,14 @@ export class User extends BaseClass {
|
||||
@Column({ nullable: true, select: false })
|
||||
email?: string; // email of the user
|
||||
|
||||
setEmail(val: string) {
|
||||
if (!val.match(/([a-z\d.-]{3,})@([a-z\d.-]+).([a-z]{2,})/g)) throw FieldErrors({ email: { message: "Invalid email", code: "EMAIL_INVALID" } });
|
||||
this.email = val;
|
||||
}
|
||||
setEmail(val?: string) {
|
||||
if (val) {
|
||||
val = adjustEmail(val);
|
||||
if (!val) throw FieldErrors({ email: { message: "Invalid email", code: "EMAIL_INVALID" } });
|
||||
if (!val.match(/([a-z\d.-]{3,})@([a-z\d.-]+).([a-z]{2,})/g)) throw FieldErrors({ email: { message: "Invalid email", code: "EMAIL_INVALID" } });
|
||||
}
|
||||
this.email = val;
|
||||
}
|
||||
|
||||
@Column()
|
||||
flags: string; // UserFlags
|
||||
|
Loading…
x
Reference in New Issue
Block a user