* Create a new user
(data: Partial<Item>, opts: MutationOptions = {})
| 206 | * Create a new user |
| 207 | */ |
| 208 | override async createOne(data: Partial<Item>, opts: MutationOptions = {}): Promise<PrimaryKey> { |
| 209 | try { |
| 210 | if ('email' in data && data['email'] !== undefined) { |
| 211 | this.validateEmail(data['email']); |
| 212 | await this.checkUniqueEmails([data['email']]); |
| 213 | } |
| 214 | |
| 215 | if ('password' in data) { |
| 216 | await this.checkPasswordPolicy([data['password']]); |
| 217 | } |
| 218 | |
| 219 | if ('provider' in data) { |
| 220 | this.checkProviderEntitlement(data['provider']); |
| 221 | } |
| 222 | } catch (err: any) { |
| 223 | opts.preMutationError = err; |
| 224 | } |
| 225 | |
| 226 | if (!('status' in data) || data['status'] === 'active') { |
| 227 | // Creating a user only requires checking user limits if the user is active, no need to care about the role |
| 228 | opts.userIntegrityCheckFlags = |
| 229 | (opts.userIntegrityCheckFlags ?? UserIntegrityCheckFlag.None) | UserIntegrityCheckFlag.UserLimits; |
| 230 | |
| 231 | opts.onRequireUserIntegrityCheck?.(opts.userIntegrityCheckFlags); |
| 232 | } |
| 233 | |
| 234 | return await super.createOne(data, opts); |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Create multiple new users |
no test coverage detected