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', 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 @@