summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-17 18:50:27 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-17 18:50:27 +1100
commit1148eaa6a2a6abf466d49f4890f7b7a57e42a67f (patch)
tree3a6c84d788a5816916509912d07a83808cf4c6ba /src
parentRemove `sharp` dep (diff)
downloadserver-1148eaa6a2a6abf466d49f4890f7b7a57e42a67f.tar.xz
user validation stuff
Diffstat (limited to 'src')
-rw-r--r--src/util/entities/BaseClass.ts2
-rw-r--r--src/util/entities/User.ts15
2 files changed, 5 insertions, 12 deletions
diff --git a/src/util/entities/BaseClass.ts b/src/util/entities/BaseClass.ts
index 74088b1e..cb97f513 100644
--- a/src/util/entities/BaseClass.ts
+++ b/src/util/entities/BaseClass.ts
@@ -71,7 +71,7 @@ export class BaseClass extends BaseClassWithoutId {
 
 	@BeforeUpdate()
 	@BeforeInsert()
-	do_validate() {
+	_do_validate() {
 		if (!this.id) this.id = Snowflake.generate();
 	}
 }
diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index 7790856a..138d94a1 100644
--- a/src/util/entities/User.ts
+++ b/src/util/entities/User.ts
@@ -195,15 +195,9 @@ export class User extends BaseClass {
 	@Column({ type: "simple-json", select: false })
 	extended_settings: string;
 
-	// @BeforeUpdate()
-	// _update_validator() { this.validate(true); }
-
-	// @BeforeInsert()
-	// _insert_validator() { this.validate(false); }
-
-	validate(/*update: boolean = false*/) {
-		// inserting or email provided in update
-		if (/*!update || */this.email) {
+	// TODO: I don't like this method?
+	validate() {
+		if (this.email) {
 			this.email = adjustEmail(this.email);
 			if (!this.email)
 				throw FieldErrors({
@@ -215,8 +209,7 @@ export class User extends BaseClass {
 				});
 		}
 
-		// inserting or discrim provided
-		if (/*!update ||*/ this.discriminator) {
+		if (this.discriminator) {
 			const discrim = Number(this.discriminator);
 			if (this.discriminator.length > 4)
 				throw FieldErrors({