From 31ea2266a68d9d41e59ea657e116fa685c0bb294 Mon Sep 17 00:00:00 2001 From: Julian Lam <julian@nodebb.org> Date: Fri, 14 Jan 2022 15:34:46 -0500 Subject: [PATCH] feat: nicer error handling for bad jwt in unsubscribe template --- install/package.json | 4 ++-- public/language/en-GB/email.json | 2 ++ src/controllers/accounts/settings.js | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/install/package.json b/install/package.json index 3de4a7f156..b52a810420 100644 --- a/install/package.json +++ b/install/package.json @@ -94,9 +94,9 @@ "nodebb-plugin-spam-be-gone": "0.7.12", "nodebb-rewards-essentials": "0.2.1", "nodebb-theme-lavender": "5.3.2", - "nodebb-theme-persona": "11.3.13", + "nodebb-theme-persona": "11.3.16", "nodebb-theme-slick": "1.4.23", - "nodebb-theme-vanilla": "12.1.15", + "nodebb-theme-vanilla": "12.1.16", "nodebb-widget-essentials": "5.0.4", "nodemailer": "6.7.2", "nprogress": "0.2.0", diff --git a/public/language/en-GB/email.json b/public/language/en-GB/email.json index 8d27730066..15cbf3cf26 100644 --- a/public/language/en-GB/email.json +++ b/public/language/en-GB/email.json @@ -61,6 +61,8 @@ "unsub.cta": "Click here to alter those settings", "unsubscribe": "unsubscribe", "unsub.success": "You will no longer receive emails from the <strong>%1</strong> mailing list", + "unsub.failure.title": "Unable to unsubscribe", + "unsub.failure.message": "Unfortunately, we were not able to unsubscribe you from the mailing list, as there was an issue with the link. However, you can alter your email preferences by going to <a href=\"%2\">your user settings</a>.<br /><br />(error: <code>%1</code>)", "banned.subject": "You have been banned from %1", "banned.text1": "The user %1 has been banned from %2.", diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js index 1331b79d95..824e12af4f 100644 --- a/src/controllers/accounts/settings.js +++ b/src/controllers/accounts/settings.js @@ -149,10 +149,12 @@ settingsController.unsubscribe = async (req, res) => { } await doUnsubscribe(payload); res.render('unsubscribe', { - payload: payload, + payload, }); } catch (err) { - throw new Error(err); + res.render('unsubscribe', { + error: err.message, + }); } };