From 0e05cbe1f749429db37743002637abbaa1796fc6 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 28 Jul 2021 15:43:51 -0400 Subject: [PATCH] feat: show instructional modal after email change request --- public/src/client/account/profile.js | 8 ++++++-- src/controllers/accounts/profile.js | 4 ++++ src/user/interstitials.js | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js index d75e451615..421c108113 100644 --- a/public/src/client/account/profile.js +++ b/public/src/client/account/profile.js @@ -3,8 +3,8 @@ define('forum/account/profile', [ 'forum/account/header', - 'components', -], function (header) { + 'bootbox', +], function (header, bootbox) { var Account = {}; Account.init = function () { @@ -14,6 +14,10 @@ define('forum/account/profile', [ processPage(); + if (parseInt(ajaxify.data.emailChanged, 10) === 1) { + bootbox.alert('[[user:emailUpdate.change-instructions]]'); + } + socket.removeListener('event:user_status_change', onUserStatusChange); socket.on('event:user_status_change', onUserStatusChange); }; diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js index 71a9f01ee6..0a505884f0 100644 --- a/src/controllers/accounts/profile.js +++ b/src/controllers/accounts/profile.js @@ -50,6 +50,10 @@ profileController.get = async function (req, res, next) { userData.title = userData.username; userData.allowCoverPicture = !userData.isSelf || !!meta.config['reputation:disabled'] || userData.reputation >= meta.config['min:rep:cover-picture']; + // Show email changed modal on first access after said change + userData.emailChanged = req.session.emailChanged; + delete req.session.emailChanged; + if (!userData.profileviews) { userData.profileviews = 1; } diff --git a/src/user/interstitials.js b/src/user/interstitials.js index 0a586b077c..5467711503 100644 --- a/src/user/interstitials.js +++ b/src/user/interstitials.js @@ -52,6 +52,7 @@ Interstitials.email = async (data) => { email: formData.email, force: true, }); + data.req.session.emailChanged = 1; } else { // User attempting to edit another user's email -- not allowed throw new Error('[[error:no-privileges]]');