fix: don't panic when no email

This commit is contained in:
Hugo Renard 2022-10-19 16:23:34 +02:00
parent d873ef6b13
commit c1bb4ca08b
Signed by: hougo
GPG key ID: 3A285FD470209C59

View file

@ -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);