fix: don't panic when no email
This commit is contained in:
parent
d873ef6b13
commit
c1bb4ca08b
1 changed files with 4 additions and 2 deletions
|
@ -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);
|
||||
|
|
Reference in a new issue