@nymphjs/tilmeld 1.0.0-beta.14 → 1.0.0-beta.140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +668 -0
- package/README.md +21 -5
- package/dist/AbleObject.d.ts +20 -2
- package/dist/AbleObject.js +25 -13
- package/dist/AbleObject.js.map +1 -1
- package/dist/Group.d.ts +190 -27
- package/dist/Group.js +827 -440
- package/dist/Group.js.map +1 -1
- package/dist/Group.testArtifacts.d.ts +3 -0
- package/dist/Group.testArtifacts.js +120 -0
- package/dist/Group.testArtifacts.js.map +1 -0
- package/dist/Tilmeld.d.ts +275 -14
- package/dist/Tilmeld.js +789 -310
- package/dist/Tilmeld.js.map +1 -1
- package/dist/Tilmeld.types.d.ts +9 -9
- package/dist/Tilmeld.types.js +1 -2
- package/dist/User.d.ts +410 -41
- package/dist/User.js +2042 -1057
- package/dist/User.js.map +1 -1
- package/dist/User.testArtifacts.d.ts +3 -0
- package/dist/User.testArtifacts.js +175 -0
- package/dist/User.testArtifacts.js.map +1 -0
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/defaults.js +215 -141
- package/dist/conf/defaults.js.map +1 -1
- package/dist/conf/index.d.ts +361 -2
- package/dist/conf/index.js +2 -8
- package/dist/conf/index.js.map +1 -1
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +3 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/requireAbility.d.ts +10 -0
- package/dist/decorators/requireAbility.js +21 -0
- package/dist/decorators/requireAbility.js.map +1 -0
- package/dist/decorators/requireAuthentication.d.ts +8 -0
- package/dist/decorators/requireAuthentication.js +16 -0
- package/dist/decorators/requireAuthentication.js.map +1 -0
- package/dist/enforceTilmeld.d.ts +3 -0
- package/dist/enforceTilmeld.js +18 -0
- package/dist/enforceTilmeld.js.map +1 -0
- package/dist/errors/AccessControlError.d.ts +2 -1
- package/dist/errors/AccessControlError.js +3 -6
- package/dist/errors/AccessControlError.js.map +1 -1
- package/dist/errors/BadDataError.d.ts +2 -1
- package/dist/errors/BadDataError.js +3 -6
- package/dist/errors/BadDataError.js.map +1 -1
- package/dist/errors/BadEmailError.d.ts +2 -1
- package/dist/errors/BadEmailError.js +3 -6
- package/dist/errors/BadEmailError.js.map +1 -1
- package/dist/errors/BadUsernameError.d.ts +2 -1
- package/dist/errors/BadUsernameError.js +3 -6
- package/dist/errors/BadUsernameError.js.map +1 -1
- package/dist/errors/CouldNotChangeDefaultPrimaryGroupError.js +1 -5
- package/dist/errors/CouldNotChangeDefaultPrimaryGroupError.js.map +1 -1
- package/dist/errors/EmailChangeRateLimitExceededError.js +1 -5
- package/dist/errors/EmailChangeRateLimitExceededError.js.map +1 -1
- package/dist/errors/index.d.ts +6 -6
- package/dist/errors/index.js +6 -22
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +10 -14
- package/dist/index.js +11 -35
- package/dist/index.js.map +1 -1
- package/dist/testArtifacts.d.ts +26 -0
- package/dist/testArtifacts.js +1346 -0
- package/dist/testArtifacts.js.map +1 -0
- package/dist/tilmeldJoiProps.d.ts +4 -5
- package/dist/tilmeldJoiProps.js +13 -18
- package/dist/tilmeldJoiProps.js.map +1 -1
- package/jest.config.js +31 -5
- package/package.json +49 -36
- package/src/AbleObject.ts +17 -11
- package/src/Group.testArtifacts.ts +159 -0
- package/src/Group.ts +712 -299
- package/src/Tilmeld.ts +666 -344
- package/src/Tilmeld.types.ts +9 -9
- package/src/User.testArtifacts.ts +226 -0
- package/src/User.ts +1984 -879
- package/src/conf/defaults.ts +205 -109
- package/src/conf/index.ts +381 -2
- package/src/decorators/index.ts +2 -0
- package/src/decorators/requireAbility.ts +26 -0
- package/src/decorators/requireAuthentication.ts +19 -0
- package/src/enforceTilmeld.ts +20 -0
- package/src/errors/AccessControlError.ts +4 -2
- package/src/errors/BadDataError.ts +4 -2
- package/src/errors/BadEmailError.ts +4 -2
- package/src/errors/BadUsernameError.ts +4 -2
- package/src/errors/index.ts +6 -6
- package/src/index.ts +11 -14
- package/src/testArtifacts.ts +2148 -0
- package/src/tilmeldJoiProps.ts +9 -24
- package/tsconfig.json +6 -3
- package/typedoc.json +4 -0
- package/dist/Group.test.d.ts +0 -1
- package/dist/Group.test.js +0 -48
- package/dist/Group.test.js.map +0 -1
- package/dist/User.test.d.ts +0 -1
- package/dist/User.test.js +0 -51
- package/dist/User.test.js.map +0 -1
- package/dist/conf/d.d.ts +0 -55
- package/dist/conf/d.js +0 -3
- package/dist/conf/d.js.map +0 -1
- package/src/Group.test.ts +0 -58
- package/src/User.test.ts +0 -61
- package/src/conf/d.ts +0 -303
package/dist/User.d.ts
CHANGED
|
@@ -1,64 +1,210 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { type EntityJson, type EntityPatch, type SerializedEntityData } from '@nymphjs/nymph';
|
|
2
|
+
import { AbleObject } from './AbleObject.js';
|
|
3
|
+
import { Group as GroupClass } from './Group.js';
|
|
4
|
+
export type EventType = 'checkUsername' | 'beforeRegister' | 'afterRegister' | 'beforeSave' | 'afterSave' | 'beforeLogin' | 'afterLogin' | 'beforeLogout' | 'afterLogout' | 'beforeDelete' | 'afterDelete';
|
|
5
|
+
/**
|
|
6
|
+
* This is run when the user has entered an otherwise valid username into the
|
|
7
|
+
* signup form. It should return a result, which when false will stop the
|
|
8
|
+
* process and return the included message, disallowing the username.
|
|
9
|
+
*/
|
|
10
|
+
export type TilmeldCheckUsernameCallback = (user: User, data: {
|
|
11
|
+
username: string;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
result: boolean;
|
|
14
|
+
message?: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* This is run before the user data checks, so the only checks before are
|
|
18
|
+
* whether registration is allowed and whether the user is already registered.
|
|
19
|
+
*/
|
|
20
|
+
export type TilmeldBeforeRegisterCallback = (user: User, data: {
|
|
7
21
|
password: string;
|
|
8
22
|
additionalData?: {
|
|
9
23
|
[k: string]: any;
|
|
10
24
|
};
|
|
11
25
|
}) => Promise<void>;
|
|
12
|
-
|
|
26
|
+
/**
|
|
27
|
+
* This is run before the transaction is committed, and you can perform
|
|
28
|
+
* additional functions on the transaction, which is available in `user.$nymph`.
|
|
29
|
+
*/
|
|
30
|
+
export type TilmeldAfterRegisterCallback = (user: User, result: {
|
|
13
31
|
loggedin: boolean;
|
|
14
32
|
message: string;
|
|
15
33
|
}) => Promise<void>;
|
|
16
|
-
|
|
34
|
+
/**
|
|
35
|
+
* This is run just before the user is saved, so all checks have passed.
|
|
36
|
+
*
|
|
37
|
+
* The transaction is available in `user.$nymph`.
|
|
38
|
+
*/
|
|
39
|
+
export type TilmeldBeforeSaveCallback = (user: User) => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* This is run before the transaction is committed, and you can perform
|
|
42
|
+
* additional functions on the transaction, which is available in `user.$nymph`.
|
|
43
|
+
*
|
|
44
|
+
* This is run after a new email verification email has been sent, so throwing
|
|
45
|
+
* an error will cause confusion for the user if they've changed their email.
|
|
46
|
+
*/
|
|
47
|
+
export type TilmeldAfterSaveCallback = (user: User) => Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* This is run after the authentication checks, but before the login action.
|
|
50
|
+
*/
|
|
51
|
+
export type TilmeldBeforeLoginCallback = (user: User, data: {
|
|
17
52
|
username: string;
|
|
18
53
|
password: string;
|
|
19
54
|
additionalData?: {
|
|
20
55
|
[k: string]: any;
|
|
21
56
|
};
|
|
22
57
|
}) => Promise<void>;
|
|
23
|
-
export type TilmeldAfterLoginCallback = (user: User
|
|
24
|
-
export type TilmeldBeforeLogoutCallback = (user: User
|
|
25
|
-
export type TilmeldAfterLogoutCallback = (user: User
|
|
26
|
-
|
|
58
|
+
export type TilmeldAfterLoginCallback = (user: User) => Promise<void>;
|
|
59
|
+
export type TilmeldBeforeLogoutCallback = (user: User) => Promise<void>;
|
|
60
|
+
export type TilmeldAfterLogoutCallback = (user: User) => Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* This is run before the user is logged out (if the current user is being
|
|
63
|
+
* deleted).
|
|
64
|
+
*
|
|
65
|
+
* The transaction is available in `user.$nymph`.
|
|
66
|
+
*/
|
|
67
|
+
export type TilmeldBeforeDeleteCallback = (user: User) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* This is run before the transaction is committed, and you can perform
|
|
70
|
+
* additional functions on the transaction, which is available in `user.$nymph`.
|
|
71
|
+
*/
|
|
72
|
+
export type TilmeldAfterDeleteCallback = (user: User) => Promise<void>;
|
|
73
|
+
export interface UserData {
|
|
74
|
+
/**
|
|
75
|
+
* The abilities granted to the user.
|
|
76
|
+
*/
|
|
27
77
|
abilities?: string[];
|
|
78
|
+
/**
|
|
79
|
+
* The user's username.
|
|
80
|
+
*/
|
|
28
81
|
username?: string;
|
|
82
|
+
/**
|
|
83
|
+
* The user's first name.
|
|
84
|
+
*/
|
|
29
85
|
nameFirst?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The user's middle name.
|
|
88
|
+
*/
|
|
30
89
|
nameMiddle?: string;
|
|
90
|
+
/**
|
|
91
|
+
* The user's last name.
|
|
92
|
+
*/
|
|
31
93
|
nameLast?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The user's full name. This is generated from the first, middle, and last
|
|
96
|
+
* names.
|
|
97
|
+
*/
|
|
32
98
|
name?: string;
|
|
99
|
+
/**
|
|
100
|
+
* The user's email address.
|
|
101
|
+
*/
|
|
33
102
|
email?: string;
|
|
103
|
+
/**
|
|
104
|
+
* The user's avatar URL. (Use $getAvatar() to support Gravatar.)
|
|
105
|
+
*/
|
|
34
106
|
avatar?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The user's telephone number.
|
|
109
|
+
*/
|
|
35
110
|
phone?: string;
|
|
36
|
-
|
|
37
|
-
|
|
111
|
+
/**
|
|
112
|
+
* The user's primary group.
|
|
113
|
+
*/
|
|
114
|
+
group?: GroupClass;
|
|
115
|
+
/**
|
|
116
|
+
* The user's secondary groups.
|
|
117
|
+
*/
|
|
118
|
+
groups?: GroupClass[];
|
|
119
|
+
/**
|
|
120
|
+
* Whether the user should inherit the abilities of his groups.
|
|
121
|
+
*/
|
|
38
122
|
inheritAbilities?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Whether the user can log in.
|
|
125
|
+
*/
|
|
39
126
|
enabled?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* A verification secret.
|
|
129
|
+
*/
|
|
40
130
|
secret?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The timestamp of when the email address was last changed.
|
|
133
|
+
*/
|
|
41
134
|
emailChangeDate?: number;
|
|
135
|
+
/**
|
|
136
|
+
* An email change proceed secret.
|
|
137
|
+
*/
|
|
42
138
|
newEmailSecret?: string;
|
|
139
|
+
/**
|
|
140
|
+
* If the user has changed their email address, this is the new one, awaiting
|
|
141
|
+
* verification.
|
|
142
|
+
*/
|
|
43
143
|
newEmailAddress?: string;
|
|
144
|
+
/**
|
|
145
|
+
* An email change cancellation secret.
|
|
146
|
+
*/
|
|
44
147
|
cancelEmailSecret?: string;
|
|
148
|
+
/**
|
|
149
|
+
* The old email address.
|
|
150
|
+
*/
|
|
45
151
|
cancelEmailAddress?: string;
|
|
152
|
+
/**
|
|
153
|
+
* A recovery secret.
|
|
154
|
+
*/
|
|
46
155
|
recoverSecret?: string;
|
|
156
|
+
/**
|
|
157
|
+
* The timestamp of when the recovery secret was issued.
|
|
158
|
+
*/
|
|
47
159
|
recoverSecretDate?: number;
|
|
160
|
+
/**
|
|
161
|
+
* The password hash salt.
|
|
162
|
+
*/
|
|
48
163
|
salt?: string;
|
|
164
|
+
/**
|
|
165
|
+
* The password or password hash.
|
|
166
|
+
*/
|
|
49
167
|
password?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Temporary storage for passwords. This will be hashed before going into the
|
|
170
|
+
* database.
|
|
171
|
+
*/
|
|
50
172
|
passwordTemp?: string;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
173
|
+
/**
|
|
174
|
+
* If set, this timestamp is the cutoff point for JWT issue dates. Any token
|
|
175
|
+
* issued before this date will not authenticate the user.
|
|
176
|
+
*/
|
|
177
|
+
revokeTokenDate?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Two factor auth secret.
|
|
180
|
+
*/
|
|
181
|
+
totpSecret?: string;
|
|
182
|
+
}
|
|
183
|
+
export interface User extends UserData {
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A user data model.
|
|
187
|
+
*
|
|
188
|
+
* Written by Hunter Perrin for SciActive.
|
|
189
|
+
*
|
|
190
|
+
* @author Hunter Perrin <hperrin@port87.com>
|
|
191
|
+
* @copyright SciActive Inc
|
|
192
|
+
* @see http://nymph.io/
|
|
193
|
+
*/
|
|
194
|
+
export declare class User extends AbleObject<UserData> {
|
|
54
195
|
static ETYPE: string;
|
|
55
196
|
static class: string;
|
|
197
|
+
private static checkUsernameCallbacks;
|
|
56
198
|
private static beforeRegisterCallbacks;
|
|
57
199
|
private static afterRegisterCallbacks;
|
|
200
|
+
private static beforeSaveCallbacks;
|
|
201
|
+
private static afterSaveCallbacks;
|
|
58
202
|
private static beforeLoginCallbacks;
|
|
59
203
|
private static afterLoginCallbacks;
|
|
60
204
|
private static beforeLogoutCallbacks;
|
|
61
205
|
private static afterLogoutCallbacks;
|
|
206
|
+
private static beforeDeleteCallbacks;
|
|
207
|
+
private static afterDeleteCallbacks;
|
|
62
208
|
private static DEFAULT_CLIENT_ENABLED_METHODS;
|
|
63
209
|
private static DEFAULT_PRIVATE_DATA;
|
|
64
210
|
private static DEFAULT_ALLOWLIST_DATA;
|
|
@@ -68,16 +214,47 @@ export default class User extends AbleObject<UserData> {
|
|
|
68
214
|
static searchRestrictedData: string[];
|
|
69
215
|
protected $allowlistData?: string[] | undefined;
|
|
70
216
|
protected $allowlistTags?: string[];
|
|
217
|
+
/**
|
|
218
|
+
* Gatekeeper ability cache.
|
|
219
|
+
*
|
|
220
|
+
* Gatekeeper will cache the user's abilities that it calculates, so it can
|
|
221
|
+
* check faster if that user has been checked before.
|
|
222
|
+
*/
|
|
71
223
|
private $gatekeeperCache?;
|
|
224
|
+
/**
|
|
225
|
+
* This should only be used by the backend.
|
|
226
|
+
*/
|
|
72
227
|
private $skipAcWhenSaving;
|
|
228
|
+
/**
|
|
229
|
+
* This should only be used by the backend.
|
|
230
|
+
*/
|
|
231
|
+
private $skipAcWhenDeleting;
|
|
232
|
+
/**
|
|
233
|
+
* The user's group descendants.
|
|
234
|
+
*/
|
|
73
235
|
private $descendantGroups?;
|
|
236
|
+
/**
|
|
237
|
+
* Used to save the current email address to send verification if it changes
|
|
238
|
+
* from the frontend.
|
|
239
|
+
*
|
|
240
|
+
* If you are changing a user's email address and want to bypass email
|
|
241
|
+
* verification, don't set this.
|
|
242
|
+
*/
|
|
74
243
|
$originalEmail?: string;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
static
|
|
80
|
-
static
|
|
244
|
+
/**
|
|
245
|
+
* Used to save the current username for domain admin permissions.
|
|
246
|
+
*/
|
|
247
|
+
$originalUsername?: string;
|
|
248
|
+
static getFTSText(name: string, value: any): string | null;
|
|
249
|
+
static factoryUsername(username?: string): Promise<User>;
|
|
250
|
+
static current(returnObjectIfNotExist: true): User;
|
|
251
|
+
static current(returnObjectIfNotExist?: false): User | null;
|
|
252
|
+
/**
|
|
253
|
+
* Send an account recovery link.
|
|
254
|
+
*
|
|
255
|
+
* @param data The input data from the client.
|
|
256
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
257
|
+
*/
|
|
81
258
|
static sendRecovery(data: {
|
|
82
259
|
recoveryType: 'username' | 'password';
|
|
83
260
|
account: string;
|
|
@@ -85,6 +262,12 @@ export default class User extends AbleObject<UserData> {
|
|
|
85
262
|
result: boolean;
|
|
86
263
|
message: string;
|
|
87
264
|
}>;
|
|
265
|
+
/**
|
|
266
|
+
* Recover account details.
|
|
267
|
+
*
|
|
268
|
+
* @param data The input data from the client.
|
|
269
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
270
|
+
*/
|
|
88
271
|
static recover(data: {
|
|
89
272
|
username: string;
|
|
90
273
|
secret: string;
|
|
@@ -97,6 +280,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
97
280
|
regFields: string[];
|
|
98
281
|
userFields: string[];
|
|
99
282
|
emailUsernames: boolean;
|
|
283
|
+
domainSupport: boolean;
|
|
100
284
|
allowRegistration: boolean;
|
|
101
285
|
allowUsernameChange: boolean;
|
|
102
286
|
pwRecovery: boolean;
|
|
@@ -106,59 +290,239 @@ export default class User extends AbleObject<UserData> {
|
|
|
106
290
|
static loginUser(data: {
|
|
107
291
|
username: string;
|
|
108
292
|
password: string;
|
|
293
|
+
code?: string;
|
|
109
294
|
additionalData?: {
|
|
110
295
|
[k: string]: any;
|
|
111
296
|
};
|
|
112
297
|
}): Promise<{
|
|
113
298
|
result: boolean;
|
|
114
299
|
message: string;
|
|
115
|
-
user?:
|
|
300
|
+
user?: User;
|
|
116
301
|
}>;
|
|
302
|
+
/**
|
|
303
|
+
* Get the users in a domain. This is only accessible to the domain's admins.
|
|
304
|
+
*/
|
|
305
|
+
static getDomainUsers(domain: string, options?: {
|
|
306
|
+
limit?: number;
|
|
307
|
+
offset?: number;
|
|
308
|
+
sort?: string;
|
|
309
|
+
reverse?: boolean;
|
|
310
|
+
}): Promise<(User & UserData)[]>;
|
|
311
|
+
constructor();
|
|
312
|
+
$getUniques(): Promise<string[]>;
|
|
117
313
|
$login(data: {
|
|
118
314
|
username: string;
|
|
119
315
|
password: string;
|
|
316
|
+
code?: string;
|
|
120
317
|
additionalData?: {
|
|
121
318
|
[k: string]: any;
|
|
122
319
|
};
|
|
123
320
|
}): Promise<{
|
|
321
|
+
result: boolean;
|
|
322
|
+
needTOTP: boolean;
|
|
323
|
+
message: string;
|
|
324
|
+
} | {
|
|
325
|
+
needTOTP?: undefined;
|
|
124
326
|
result: boolean;
|
|
125
327
|
message: any;
|
|
126
328
|
}>;
|
|
329
|
+
$switchUser(data?: {
|
|
330
|
+
additionalData?: {
|
|
331
|
+
[k: string]: any;
|
|
332
|
+
};
|
|
333
|
+
}): Promise<{
|
|
334
|
+
result: boolean;
|
|
335
|
+
message: string;
|
|
336
|
+
}>;
|
|
337
|
+
/**
|
|
338
|
+
* Log a user out of the system.
|
|
339
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
340
|
+
*/
|
|
127
341
|
$logout(): Promise<{
|
|
128
342
|
result: boolean;
|
|
129
|
-
message:
|
|
343
|
+
message: string;
|
|
130
344
|
}>;
|
|
131
345
|
$getAvatar(): string;
|
|
132
|
-
$
|
|
133
|
-
$
|
|
346
|
+
$getGid(): string | null;
|
|
347
|
+
$getGids(): string[] | null;
|
|
348
|
+
/**
|
|
349
|
+
* Get the user's group descendants.
|
|
350
|
+
*/
|
|
351
|
+
$getDescendantGroups(): Promise<GroupClass[]>;
|
|
134
352
|
$jsonAcceptData(input: EntityJson, allowConflict?: boolean): void;
|
|
135
353
|
$jsonAcceptPatch(patch: EntityPatch, allowConflict?: boolean): void;
|
|
136
|
-
$
|
|
137
|
-
$
|
|
138
|
-
|
|
354
|
+
private $checkIncomingAbilities;
|
|
355
|
+
$putData(data: UserData, sdata?: SerializedEntityData, source?: 'server'): void;
|
|
356
|
+
/**
|
|
357
|
+
* Update the data protection arrays for the current user.
|
|
358
|
+
*/
|
|
359
|
+
$updateDataProtection(): void;
|
|
360
|
+
$updateGroupDataProtection(): void;
|
|
361
|
+
/**
|
|
362
|
+
* Check to see if a user has an ability.
|
|
363
|
+
*
|
|
364
|
+
* This function will check both user and group abilities, if the user is
|
|
365
|
+
* marked to inherit the abilities of its group.
|
|
366
|
+
*
|
|
367
|
+
* If `ability` is undefined, it will check to see if the user is currently
|
|
368
|
+
* logged in.
|
|
369
|
+
*
|
|
370
|
+
* If the user has the "system/admin" ability, this function will return true.
|
|
371
|
+
*
|
|
372
|
+
* @param ability The ability.
|
|
373
|
+
* @returns True or false.
|
|
374
|
+
*/
|
|
375
|
+
$gatekeeper(ability?: string): Promise<boolean>;
|
|
376
|
+
/**
|
|
377
|
+
* Build a gatekeeper cache object.
|
|
378
|
+
*/
|
|
379
|
+
$getGatekeeperCache(): Promise<{
|
|
380
|
+
[k: string]: true;
|
|
381
|
+
}>;
|
|
139
382
|
$clearCache(): void;
|
|
383
|
+
/**
|
|
384
|
+
* Send the user email verification/change/cancellation links.
|
|
385
|
+
*
|
|
386
|
+
* @returns True on success, false on failure.
|
|
387
|
+
*/
|
|
140
388
|
$sendEmailVerification(): Promise<boolean>;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
389
|
+
/**
|
|
390
|
+
* Add the user to a (secondary) group.
|
|
391
|
+
*
|
|
392
|
+
* @param group The group.
|
|
393
|
+
* @returns True if the user is already in the group. The resulting array of groups if the user was not.
|
|
394
|
+
*/
|
|
395
|
+
$addGroup(group: GroupClass): Promise<true | GroupClass[]>;
|
|
396
|
+
/**
|
|
397
|
+
* Check the given password against the user's.
|
|
398
|
+
*
|
|
399
|
+
* @param password The password in question.
|
|
400
|
+
* @returns True if the passwords match, otherwise false.
|
|
401
|
+
*/
|
|
402
|
+
$checkPassword(password: string): Promise<boolean>;
|
|
403
|
+
/**
|
|
404
|
+
* Remove the user from a (secondary) group.
|
|
405
|
+
*
|
|
406
|
+
* @param group The group.
|
|
407
|
+
* @returns True if the user wasn't in the group. The resulting array of groups if the user was.
|
|
408
|
+
*/
|
|
409
|
+
$delGroup(group: GroupClass): Promise<true | GroupClass[]>;
|
|
410
|
+
/**
|
|
411
|
+
* Check whether the user is in a (primary or secondary) group.
|
|
412
|
+
*
|
|
413
|
+
* @param group The group, or the group's GUID.
|
|
414
|
+
* @returns True or false.
|
|
415
|
+
*/
|
|
416
|
+
$inGroup(group: GroupClass | string): Promise<boolean>;
|
|
417
|
+
/**
|
|
418
|
+
* Check whether the user is a descendant of a group.
|
|
419
|
+
*
|
|
420
|
+
* @param group The group, or the group's GUID.
|
|
421
|
+
* @returns True or false.
|
|
422
|
+
*/
|
|
423
|
+
$isDescendant(group: GroupClass | string): Promise<boolean>;
|
|
424
|
+
/**
|
|
425
|
+
* A frontend accessible method to change the user's password.
|
|
426
|
+
*
|
|
427
|
+
* @param data The input data from the client.
|
|
428
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
429
|
+
*/
|
|
146
430
|
$changePassword(data: {
|
|
147
431
|
newPassword: string;
|
|
148
432
|
currentPassword: string;
|
|
433
|
+
revokeCurrentTokens?: boolean;
|
|
434
|
+
}): Promise<{
|
|
435
|
+
result: boolean;
|
|
436
|
+
message: string;
|
|
437
|
+
}>;
|
|
438
|
+
/**
|
|
439
|
+
* Change the user's password.
|
|
440
|
+
*
|
|
441
|
+
* @param password The new password.
|
|
442
|
+
* @returns The resulting password or hash which is stored in the entity.
|
|
443
|
+
*/
|
|
444
|
+
$password(password: string): Promise<string>;
|
|
445
|
+
/**
|
|
446
|
+
* A frontend accessible method to revoke all currently issued tokens.
|
|
447
|
+
*
|
|
448
|
+
* @param data The input data from the client.
|
|
449
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
450
|
+
*/
|
|
451
|
+
$revokeCurrentTokens(data?: {
|
|
452
|
+
password: string;
|
|
453
|
+
}): Promise<{
|
|
454
|
+
result: boolean;
|
|
455
|
+
message: string;
|
|
456
|
+
}>;
|
|
457
|
+
$hasTOTPSecret(): boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Check the given code against the user's TOTP secret.
|
|
460
|
+
*
|
|
461
|
+
* @param code The code in question.
|
|
462
|
+
* @returns True if the code is valid, otherwise false.
|
|
463
|
+
*/
|
|
464
|
+
$checkTOTPCode(code: string): boolean;
|
|
465
|
+
/**
|
|
466
|
+
* A frontend accessible method to generate a new TOTP secret.
|
|
467
|
+
*
|
|
468
|
+
* @returns An object with 'uri', 'qrcode', and 'secret'.
|
|
469
|
+
*/
|
|
470
|
+
$getNewTOTPSecret(): Promise<{
|
|
471
|
+
uri: string;
|
|
472
|
+
qrcode: string;
|
|
473
|
+
secret: string;
|
|
474
|
+
}>;
|
|
475
|
+
/**
|
|
476
|
+
* A frontend accessible method to save a TOTP secret into the user's account.
|
|
477
|
+
*
|
|
478
|
+
* @param data The input data from the client.
|
|
479
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
480
|
+
*/
|
|
481
|
+
$saveTOTPSecret(data: {
|
|
482
|
+
password: string;
|
|
483
|
+
secret: string;
|
|
484
|
+
code: string;
|
|
485
|
+
}): Promise<{
|
|
486
|
+
result: boolean;
|
|
487
|
+
message: string;
|
|
488
|
+
}>;
|
|
489
|
+
/**
|
|
490
|
+
* A frontend accessible method to remove the TOTP secret from the user's
|
|
491
|
+
* account.
|
|
492
|
+
*
|
|
493
|
+
* @param data The input data from the client.
|
|
494
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
495
|
+
*/
|
|
496
|
+
$removeTOTPSecret(data?: {
|
|
497
|
+
password: string;
|
|
498
|
+
code: string;
|
|
149
499
|
}): Promise<{
|
|
150
500
|
result: boolean;
|
|
151
501
|
message: string;
|
|
152
502
|
}>;
|
|
153
|
-
|
|
503
|
+
/**
|
|
504
|
+
* Check that a username is valid.
|
|
505
|
+
*
|
|
506
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
507
|
+
*/
|
|
154
508
|
$checkUsername(): Promise<{
|
|
155
509
|
result: boolean;
|
|
156
510
|
message: string;
|
|
157
511
|
}>;
|
|
512
|
+
/**
|
|
513
|
+
* Check that an email is unique.
|
|
514
|
+
*
|
|
515
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
516
|
+
*/
|
|
158
517
|
$checkEmail(): Promise<{
|
|
159
518
|
result: boolean;
|
|
160
519
|
message: string;
|
|
161
520
|
}>;
|
|
521
|
+
/**
|
|
522
|
+
* Check that a phone number is unique.
|
|
523
|
+
*
|
|
524
|
+
* @returns An object with a boolean 'result' entry and a 'message' entry.
|
|
525
|
+
*/
|
|
162
526
|
$checkPhone(): Promise<{
|
|
163
527
|
result: boolean;
|
|
164
528
|
message: string;
|
|
@@ -173,10 +537,15 @@ export default class User extends AbleObject<UserData> {
|
|
|
173
537
|
loggedin: boolean;
|
|
174
538
|
message: string;
|
|
175
539
|
}>;
|
|
176
|
-
$save(): Promise<
|
|
177
|
-
|
|
540
|
+
$save(): Promise<void>;
|
|
541
|
+
/**
|
|
542
|
+
* This should *never* be accessible on the client.
|
|
543
|
+
*/
|
|
544
|
+
$saveSkipAC(): Promise<void>;
|
|
178
545
|
$tilmeldSaveSkipAC(): boolean;
|
|
179
|
-
$delete(): Promise<
|
|
180
|
-
|
|
181
|
-
|
|
546
|
+
$delete(): Promise<void>;
|
|
547
|
+
$deleteSkipAC(): Promise<void>;
|
|
548
|
+
$tilmeldDeleteSkipAC(): boolean;
|
|
549
|
+
static on<T extends EventType>(event: T, callback: T extends 'checkUsername' ? TilmeldCheckUsernameCallback : T extends 'beforeRegister' ? TilmeldBeforeRegisterCallback : T extends 'afterRegister' ? TilmeldAfterRegisterCallback : T extends 'beforeSave' ? TilmeldBeforeSaveCallback : T extends 'afterSave' ? TilmeldAfterSaveCallback : T extends 'beforeLogin' ? TilmeldBeforeLoginCallback : T extends 'afterLogin' ? TilmeldAfterLoginCallback : T extends 'beforeLogout' ? TilmeldBeforeLogoutCallback : T extends 'afterLogout' ? TilmeldAfterLogoutCallback : T extends 'beforeDelete' ? TilmeldBeforeDeleteCallback : T extends 'afterDelete' ? TilmeldAfterDeleteCallback : never): () => boolean;
|
|
550
|
+
static off<T extends EventType>(event: T, callback: T extends 'checkUsername' ? TilmeldCheckUsernameCallback : T extends 'beforeRegister' ? TilmeldBeforeRegisterCallback : T extends 'afterRegister' ? TilmeldAfterRegisterCallback : T extends 'beforeSave' ? TilmeldBeforeSaveCallback : T extends 'afterSave' ? TilmeldAfterSaveCallback : T extends 'beforeLogin' ? TilmeldBeforeLoginCallback : T extends 'afterLogin' ? TilmeldAfterLoginCallback : T extends 'beforeLogout' ? TilmeldBeforeLogoutCallback : T extends 'afterLogout' ? TilmeldAfterLogoutCallback : T extends 'beforeDelete' ? TilmeldBeforeDeleteCallback : T extends 'afterDelete' ? TilmeldAfterDeleteCallback : never): boolean;
|
|
182
551
|
}
|