diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/user.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/server/models/user.js b/server/models/user.js index 24e710fa7..e64bab8ab 100644 --- a/server/models/user.js +++ b/server/models/user.js | |||
@@ -39,6 +39,17 @@ module.exports = function (sequelize, DataTypes) { | |||
39 | isEmail: true | 39 | isEmail: true |
40 | } | 40 | } |
41 | }, | 41 | }, |
42 | displayNSFW: { | ||
43 | type: DataTypes.BOOLEAN, | ||
44 | allowNull: false, | ||
45 | defaultValue: false, | ||
46 | validate: { | ||
47 | nsfwValid: function (value) { | ||
48 | const res = customUsersValidators.isUserDisplayNSFWValid(value) | ||
49 | if (res === false) throw new Error('Display NSFW is not valid.') | ||
50 | } | ||
51 | } | ||
52 | }, | ||
42 | role: { | 53 | role: { |
43 | type: DataTypes.ENUM(values(constants.USER_ROLES)), | 54 | type: DataTypes.ENUM(values(constants.USER_ROLES)), |
44 | allowNull: false | 55 | allowNull: false |
@@ -101,6 +112,7 @@ function toFormatedJSON () { | |||
101 | id: this.id, | 112 | id: this.id, |
102 | username: this.username, | 113 | username: this.username, |
103 | email: this.email, | 114 | email: this.email, |
115 | displayNSFW: this.displayNSFW, | ||
104 | role: this.role, | 116 | role: this.role, |
105 | createdAt: this.createdAt | 117 | createdAt: this.createdAt |
106 | } | 118 | } |