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 { public static fromRC(rc: IUser): SCIMUser {
const user = new SCIMUser(); const user = new SCIMUser();
user.id = rc._id; user.id = rc._id;
if (rc.emails && rc.emails.length > 0) {
const email = rc.emails[0]; const email = rc.emails[0];
user.emails = [{ primary: true, value: email.address }]; user.emails = [{ primary: true, value: email.address }];
}
user.displayName = rc.name; user.displayName = rc.name;
user.userName = rc.username; user.userName = rc.username;
user.meta.created = new Date(rc.createdAt); user.meta.created = new Date(rc.createdAt);