From c8ca91bdd206259fcbc7e6446b261271318c2746 Mon Sep 17 00:00:00 2001 From: Matthias Pfeil Date: Wed, 1 Mar 2023 15:32:20 +0100 Subject: [PATCH 1/2] fix(account): email address must be confirmed account can only be used if the user confirmed the associated email address with the account --- app/scripts/app.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/scripts/app.js b/app/scripts/app.js index cd9a5d5d..6d52572d 100644 --- a/app/scripts/app.js +++ b/app/scripts/app.js @@ -195,6 +195,13 @@ data: { requiresLogin: true, }, + resolve: { + emailConfirmed: function (AccountService) { + return AccountService.getUserDetails().then(function (data) { + return data.data.me.emailIsConfirmed; + }); + } + } }) .state('account.dataupload', { url: '/:id/dataupload', @@ -366,6 +373,11 @@ templateUrl: 'views/account.dashboard.html', }, }, + onEnter: function ($state, emailConfirmed) { + if (!emailConfirmed) { + $state.go('account.settings'); + } + } }) .state('account.settings', { url: '/settings', @@ -422,6 +434,11 @@ templateUrl: 'views/account.box.register.html', }, }, + onEnter: function ($state, emailConfirmed) { + if (!emailConfirmed) { + $state.go('account.settings'); + } + } }) .state('register', { url: '/register', From 43d145f1b96123bc1a9b87f6a68a2fd0b87fc6b3 Mon Sep 17 00:00:00 2001 From: Matthias Pfeil Date: Wed, 1 Mar 2023 17:43:42 +0100 Subject: [PATCH 2/2] Add resend button --- app/scripts/controllers/account.settings.js | 10 ++++++++++ app/scripts/services/account.js | 13 ++++++++++++- app/views/account.settings.html | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/account.settings.js b/app/scripts/controllers/account.settings.js index f727e3dd..b4341bce 100644 --- a/app/scripts/controllers/account.settings.js +++ b/app/scripts/controllers/account.settings.js @@ -21,6 +21,7 @@ vm.updateDisabled = updateDisabled; vm.changeAttribute = changeAttribute; vm.deleteAccount = deleteAccount; + vm.resendEmailConfirmation = resendEmailConfirmation; activate(); @@ -42,6 +43,15 @@ }); } + function resendEmailConfirmation () { + vm.alerts.pop(); + + return AccountService.resendEmailConfirmation() + .then(function (data) { + vm.alerts.push({ type: 'info', msg: data.message }); + }); + } + function updateAccount () { vm.alerts.pop(); if (angular.isDefined(vm.currentPassword)) { diff --git a/app/scripts/services/account.js b/app/scripts/services/account.js index 8f03add9..956dd8c9 100644 --- a/app/scripts/services/account.js +++ b/app/scripts/services/account.js @@ -31,7 +31,8 @@ transferDevice: transferDevice, revokeToken: revokeToken, getTransferToken: getTransferToken, - claimDevice: claimDevice + claimDevice: claimDevice, + resendEmailConfirmation: resendEmailConfirmation }; return service; @@ -296,5 +297,15 @@ }) .catch(failed); } + + function resendEmailConfirmation (data) { + return $http.post(app.API_URL + '/users/me/resend-email-confirmation', data, { + auth: true + }) + .then(function (response) { + return response.data; + }) + .catch(failed); + } } })(); diff --git a/app/views/account.settings.html b/app/views/account.settings.html index d90bb18a..16c1b9ea 100644 --- a/app/views/account.settings.html +++ b/app/views/account.settings.html @@ -20,6 +20,7 @@

{{'ACCOUNT_TITLE'|translate}}

{{'ACCOUNT_MAIL_NOT_CONFIRMED'|translate}} {{'ACCOUNT_MAIL_CONFIRMED'|translate}} +