chore: Audit of all model column validations (#3757)

* chore: Updating all model validations before the white-hatters get to it ;)

* test

* Remove isUrl validation, thinking about it need to account for minio and other weird urls here
This commit is contained in:
Tom Moor
2022-07-09 17:04:40 +02:00
committed by GitHub
parent da4a10e877
commit 8bb88b8550
13 changed files with 100 additions and 19 deletions

View File

@@ -17,6 +17,7 @@ import {
DataType,
HasMany,
Scopes,
IsDate,
} from "sequelize-typescript";
import { languages } from "@shared/i18n";
import { stringToColor } from "@shared/utils/color";
@@ -84,17 +85,17 @@ export enum UserFlag {
@Fix
class User extends ParanoidModel {
@IsEmail
@Length({ max: 255, msg: "User email must be less than 255 characters" })
@Length({ max: 255, msg: "User email must be 255 characters or less" })
@Column
email: string | null;
@NotContainsUrl
@Length({ max: 255, msg: "User username must be less than 255 characters" })
@Length({ max: 255, msg: "User username must be 255 characters or less" })
@Column
username: string | null;
@NotContainsUrl
@Length({ max: 255, msg: "User name must be less than 255 characters" })
@Length({ max: 255, msg: "User name must be 255 characters or less" })
@Column
name: string;
@@ -116,6 +117,7 @@ class User extends ParanoidModel {
setEncryptedColumn(this, "jwtSecret", value);
}
@IsDate
@Column
lastActiveAt: Date | null;
@@ -123,6 +125,7 @@ class User extends ParanoidModel {
@Column
lastActiveIp: string | null;
@IsDate
@Column
lastSignedInAt: Date | null;
@@ -130,9 +133,11 @@ class User extends ParanoidModel {
@Column
lastSignedInIp: string | null;
@IsDate
@Column
lastSigninEmailSentAt: Date | null;
@IsDate
@Column
suspendedAt: Date | null;
@@ -144,11 +149,7 @@ class User extends ParanoidModel {
@Column
language: string;
@Length({
min: 0,
max: 1000,
msg: "avatarUrl must be less than 1000 characters",
})
@Length({ max: 1000, msg: "avatarUrl must be less than 1000 characters" })
@Column(DataType.STRING)
get avatarUrl() {
const original = this.getDataValue("avatarUrl");