@@ -17,6 +17,73 @@ import getOrgFromAuthInfo from 'lib/services/auth/authInfoSelectors/getOrgFromAu
1717import getUserIdFromAuthInfo from 'lib/services/auth/authInfoSelectors/getUserIdFromAuthInfo' ;
1818import { validatePasswordUtil } from 'lib/utils/validators/User' ;
1919
20+ /**
21+ * @typedef {object } PasswordHistoryItem
22+ * @property {string } hash
23+ * @property {Date } date
24+ */
25+
26+ /**
27+ * @typedef {object } ResetTokensItem
28+ * @property {string } token
29+ * @property {Date } expires
30+ */
31+
32+ /**
33+ * @typedef {object } UserSettings
34+ * @property {boolean } CONFIRM_BEFORE_DELETE
35+ */
36+
37+ /**
38+ * @typedef {object } OrganisationSettings
39+ * @property {object } organisation - TODO: define type
40+ * @property {string[] } scopes
41+ * @property {object[] } roles - TODO: define type
42+ * @property {string } filter
43+ * @property {string } oldFilter
44+ * @property {string } timezone
45+ */
46+
47+ /**
48+ * @typedef {object } OwnerOrganisationSettings
49+ * @property {boolean } LOCKOUT_ENABLED
50+ * @property {number } LOCKOUT_ATTEMPS
51+ * @property {number } LOCKOUT_SECONDS
52+ * @property {boolean } PASSWORD_HISTORY_CHECK
53+ * @property {number } PASSWORD_HISTORY_TOTAL
54+ * @property {number } PASSWORD_MIN_LENGTH
55+ * @property {boolean } PASSWORD_REQUIRE_ALPHA
56+ * @property {boolean } PASSWORD_REQUIRE_NUMBER
57+ * @property {boolean } PASSWORD_USE_CUSTOM_REGEX
58+ * @property {string } PASSWORD_CUSTOM_REGEX
59+ * @property {string } PASSWORD_CUSTOM_MESSAGE
60+ */
61+
62+ /**
63+ * Plain object structure without mongoose model methods
64+ * @typedef {object } User
65+ * @property {string } name
66+ * @property {string } email
67+ * @property {object[] } organisations - TODO: define type
68+ * @property {OrganisationSettings[] } organisationSettings
69+ * @property {string } imageUrl
70+ * @property {string } googleId
71+ * @property {string } password
72+ * @property {object } ownerOrganisation - TODO: define type
73+ * @property {OwnerOrganisationSettings } ownerOrganisationSettings
74+ * @property {UserSettings } settings
75+ * @property {string[] } scopes
76+ * @property {boolean } verified
77+ * @property {ResetTokensItem[] } resetTokens
78+ * @property {PasswordHistoryItem[] } passwordHistory
79+ * @property {Date } authLastAttempt
80+ * @property {number } authFailedAttempts
81+ * @property {Date } authLockoutExpiry
82+ * @property {boolean } hasBeenMigrated
83+ */
84+
85+ /** @typedef {module:mongoose.Model<User> } UserModel */
86+
2087/**
2188 * @param {string } value
2289 * @returns {true } if validation is success
@@ -63,6 +130,7 @@ async function validatePassword(value) {
63130}
64131
65132// TODO: Remove `organisationSettings.oldFilter` and `hasBeenMigrated` after we confirm success of $in migration
133+ /** @class UserSchema */
66134const schema = new mongoose . Schema ( {
67135 name : { type : String } ,
68136 email : {
@@ -110,6 +178,7 @@ const schema = new mongoose.Schema({
110178 // "owned" users when the organisation's settings are updated
111179 ownerOrganisationSettings : {
112180 LOCKOUT_ENABLED : { type : Boolean , default : true } ,
181+ // TODO: fix typo 🤨
113182 LOCKOUT_ATTEMPS : { type : Number , default : 5 } , // number of attempts before lock out
114183 LOCKOUT_SECONDS : { type : Number , default : 1800 } , // 30 minute lock out period
115184
0 commit comments