diff --git a/src/scim/User.ts b/src/scim/User.ts index 8ab5e1a..58de90b 100644 --- a/src/scim/User.ts +++ b/src/scim/User.ts @@ -24,8 +24,10 @@ export class SCIMUser implements ISCIMResource { public static fromRC(rc: IUser): SCIMUser { const user = new SCIMUser(); user.id = rc._id; - const email = rc.emails[0]; - user.emails = [{ primary: true, value: email.address }]; + if (rc.emails && rc.emails.length > 0) { + const email = rc.emails[0]; + user.emails = [{ primary: true, value: email.address }]; + } user.displayName = rc.name; user.userName = rc.username; user.meta.created = new Date(rc.createdAt);