(user = {}, fallback = {})
| 271 | } |
| 272 | |
| 273 | function normalizeUser(user = {}, fallback = {}) { |
| 274 | const source = { |
| 275 | ...fallback, |
| 276 | ...user, |
| 277 | }; |
| 278 | |
| 279 | return { |
| 280 | ...source, |
| 281 | id: toTrimmedString(source.id), |
| 282 | firstName: toTrimmedString(source.firstName), |
| 283 | lastName: toTrimmedString(source.lastName), |
| 284 | phoneNumber: toTrimmedString(source.phoneNumber), |
| 285 | email: toTrimmedString(source.email), |
| 286 | role: normalizeRole(source.role), |
| 287 | disabled: Boolean(source.disabled), |
| 288 | avatar: normalizeAvatar(source.avatar), |
| 289 | password: toTrimmedString(source.password), |
| 290 | emailVerified: |
| 291 | typeof source.emailVerified === 'boolean' ? source.emailVerified : true, |
| 292 | emailVerificationToken: source.emailVerificationToken ?? null, |
| 293 | emailVerificationTokenExpiresAt: |
| 294 | source.emailVerificationTokenExpiresAt ?? null, |
| 295 | passwordResetToken: source.passwordResetToken ?? null, |
| 296 | passwordResetTokenExpiresAt: source.passwordResetTokenExpiresAt ?? null, |
| 297 | provider: toTrimmedString(source.provider) || 'local', |
| 298 | }; |
| 299 | } |
| 300 | |
| 301 | function cloneUsers(users) { |
| 302 | return users.map((user) => ({ |
no test coverage detected