1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 12:42:44 +01:00

Merge pull request #2 from haydaralqassam/fraudcord

Small fix for tag digit and undefined email
This commit is contained in:
Madeline 2022-09-20 16:27:31 +10:00 committed by GitHub
commit e23459f774
2 changed files with 19 additions and 2 deletions

View File

@ -74,7 +74,13 @@ export class Member extends BaseClassWithoutId {
nick?: string;
setNick(val: string) {
if (val && BannedWords.find(val)) throw FieldErrors({ nick: { message: "Bad nickname", code: "INVALID_NICKNAME" } });
if (val) {
val = val.split("\n").join("");
val = val.split("\t").join("");
if (BannedWords.find(val)) throw FieldErrors({ nick: { message: "Bad nickname", code: "INVALID_NICKNAME" } });
}
this.nick = val;
}

View File

@ -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 {
@ -69,8 +69,10 @@ export class User extends BaseClass {
setDiscriminator(val: string) {
const number = Number(val);
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();
this.discriminator = val.toString().padStart(4, "0");
}
@ -137,6 +139,15 @@ export class User extends BaseClass {
@Column({ nullable: true, select: false })
email?: string; // email of the user
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