From 78329c243d9ad285cf1c998f285a5b65c8e6fa5a Mon Sep 17 00:00:00 2001 From: Rosanny <rosanny.sihombing@hft-stuttgart.de> Date: Tue, 21 Sep 2021 15:27:33 +0200 Subject: [PATCH] add customized error when user data is not found --- routes/account.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/routes/account.ts b/routes/account.ts index 68c3ca61..ce921c56 100644 --- a/routes/account.ts +++ b/routes/account.ts @@ -106,10 +106,14 @@ export = function (app:any, config:any, passport:any, lang:string) { res.redirect('/login') } else { let loggedInUser = await getLoggedInUserData(req.user.email) - - res.render(lang+'/account/home', { - user: loggedInUser - }); + if (!loggedInUser) { + console.error("user data is not found") + res.status(500).render(lang+'/500', { error: "Your data is not found. Please try again." }) + } else { + res.render(lang+'/account/home', { + user: loggedInUser + }); + } } }); -- GitLab