From fe9de408f47b168a8916f1546edebf67829be76a Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Fri, 19 May 2023 18:57:42 +0200
Subject: [PATCH] [fix] Fix error 'pub is undefined' in wot

---
 app/modules/bma/lib/controllers/wot.ts | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/app/modules/bma/lib/controllers/wot.ts b/app/modules/bma/lib/controllers/wot.ts
index 73422c518..3297de123 100644
--- a/app/modules/bma/lib/controllers/wot.ts
+++ b/app/modules/bma/lib/controllers/wot.ts
@@ -142,10 +142,13 @@ export class WOTBinding extends AbstractController {
         search
       )) as FullIindexEntry;
     }
-    const certs = await this.server.dal.certsToTarget(
-      idty.pub,
-      IdentityDTO.getTargetHash(idty)
-    );
+    const certs =
+      (idty &&
+        (await this.server.dal.certsToTarget(
+          idty.pub,
+          IdentityDTO.getTargetHash(idty)
+        ))) ||
+      [];
     const theCerts: HttpCertification[] = [];
     for (const cert of certs) {
       const certifier = await this.server.dal.getWrittenIdtyByPubkeyForUidAndMemberAndCreatedOn(
@@ -254,7 +257,7 @@ export class WOTBinding extends AbstractController {
         search
       )) as FullIindexEntry;
     }
-    const certs = await this.server.dal.certsFrom(idty.pub);
+    const certs = (idty && (await this.server.dal.certsFrom(idty.pub))) || [];
     const theCerts: HttpCertification[] = [];
     for (const cert of certs) {
       const certified = await this.server.dal.getWrittenIdtyByPubkeyForUidAndMemberAndCreatedOn(
-- 
GitLab