MCPcopy Create free account
hub / github.com/flatlogic/react-material-admin / normalizeUser

Function normalizeUser

src/repositories/usersMockRepository.js:273–299  ·  view source on GitHub ↗
(user = {}, fallback = {})

Source from the content-addressed store, hash-verified

271}
272
273function 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
301function cloneUsers(users) {
302 return users.map((user) => ({

Callers 3

createMockUserFunction · 0.85
updateMockUserFunction · 0.85

Calls 3

toTrimmedStringFunction · 0.85
normalizeRoleFunction · 0.85
normalizeAvatarFunction · 0.85

Tested by

no test coverage detected