diff --git a/src/app/accounts/accountsOrganizationAcceptController.js b/src/app/accounts/accountsOrganizationAcceptController.js index 6bb18dc8..8ff0164e 100644 --- a/src/app/accounts/accountsOrganizationAcceptController.js +++ b/src/app/accounts/accountsOrganizationAcceptController.js @@ -42,8 +42,4 @@ angular $scope.loading = false; } }); - - $scope.submit = function (model) { - - }; }); diff --git a/src/app/accounts/accountsVerifyEmailController.js b/src/app/accounts/accountsVerifyEmailController.js new file mode 100644 index 00000000..8abcd366 --- /dev/null +++ b/src/app/accounts/accountsVerifyEmailController.js @@ -0,0 +1,28 @@ +angular + .module('bit.accounts') + + .controller('accountsVerifyEmailController', function ($scope, $state, apiService, toastr, $analytics) { + if (!$state.params.userId || !$state.params.token) { + $state.go('frontend.login.info').then(function () { + toastr.error('Invalid parameters.'); + }); + return; + } + + $scope.$on('$viewContentLoaded', function () { + apiService.accounts.verifyEmailToken({}, + { + token: $state.params.token, + userId: $state.params.userId + }, function () { + $analytics.eventTrack('Verified Email'); + $state.go('frontend.login.info', null, { location: 'replace' }).then(function () { + toastr.success('Your email has been verified. Thank you.', 'Success'); + }); + }, function () { + $state.go('frontend.login.info', null, { location: 'replace' }).then(function () { + toastr.error('Unable to verify email.', 'Error'); + }); + }); + }); + }); diff --git a/src/app/accounts/views/accountsVerifyEmail.html b/src/app/accounts/views/accountsVerifyEmail.html new file mode 100644 index 00000000..7bd695ea --- /dev/null +++ b/src/app/accounts/views/accountsVerifyEmail.html @@ -0,0 +1,8 @@ +
+ +
+ Verifying email... +
+
diff --git a/src/app/config.js b/src/app/config.js index 1d883e64..1f317c4e 100644 --- a/src/app/config.js +++ b/src/app/config.js @@ -7,7 +7,7 @@ angular $locationProvider.hashPrefix(''); jwtOptionsProvider.config({ urlParam: 'access_token3', - whiteListedDomains: ['api.bitwarden.com', 'preview-api.bitwarden.com', 'localhost', '192.168.1.6'] + whiteListedDomains: ['api.bitwarden.com', 'preview-api.bitwarden.com', 'localhost', '192.168.1.4'] }); var refreshPromise; jwtInterceptorProvider.tokenGetter = /*@ngInject*/ function (options, tokenService, authService) { @@ -260,6 +260,16 @@ angular bodyClass: 'login-page', skipAuthorize: true } + }) + .state('frontend.verifyEmail', { + url: '^/verify-email?userId&token', + templateUrl: 'app/accounts/views/accountsVerifyEmail.html', + controller: 'accountsVerifyEmailController', + data: { + pageTitle: 'Verifying Email', + bodyClass: 'login-page', + skipAuthorize: true + } }); }) .run(function ($rootScope, authService, $state) { diff --git a/src/app/global/mainController.js b/src/app/global/mainController.js index 3bddb0be..7e9e4f7f 100644 --- a/src/app/global/mainController.js +++ b/src/app/global/mainController.js @@ -2,7 +2,7 @@ angular .module('bit.global') .controller('mainController', function ($scope, $state, authService, appSettings, toastr, $window, $document, - cryptoService, $uibModal) { + cryptoService, $uibModal, apiService) { var vm = this; vm.bodyClass = ''; vm.usingControlSidebar = vm.openControlSidebar = false; @@ -79,7 +79,19 @@ angular }; $scope.verifyEmail = function () { - // TODO: send email api + if ($scope.sendingVerify) { + return; + } + + $scope.sendingVerify = true; + apiService.accounts.verifyEmail({}, null).$promise.then(function () { + toastr.success('Verification email sent.'); + $scope.sendingVerify = false; + $scope.verifyEmailSent = true; + }).catch(function () { + toastr.success('Verification email failed.'); + $scope.sendingVerify = false; + }); }; // Append dropdown menu somewhere else diff --git a/src/app/services/apiService.js b/src/app/services/apiService.js index e2a5b989..17cc3868 100644 --- a/src/app/services/apiService.js +++ b/src/app/services/apiService.js @@ -104,6 +104,8 @@ register: { url: _apiUri + '/accounts/register', method: 'POST', params: {} }, emailToken: { url: _apiUri + '/accounts/email-token', method: 'POST', params: {} }, email: { url: _apiUri + '/accounts/email', method: 'POST', params: {} }, + verifyEmailToken: { url: _apiUri + '/accounts/verify-email-token', method: 'POST', params: {} }, + verifyEmail: { url: _apiUri + '/accounts/verify-email', method: 'POST', params: {} }, putPassword: { url: _apiUri + '/accounts/password', method: 'POST', params: {} }, getProfile: { url: _apiUri + '/accounts/profile', method: 'GET', params: {} }, putProfile: { url: _apiUri + '/accounts/profile', method: 'POST', params: {} }, diff --git a/src/app/views/userLayout.html b/src/app/views/userLayout.html index 30230308..4da1bfa7 100644 --- a/src/app/views/userLayout.html +++ b/src/app/views/userLayout.html @@ -144,8 +144,16 @@

Verify Your Email

- Verify your account's email address to unlock access to all features. - Send verification email now. +
+ Verify your account's email address to unlock access to all features. + Send verification email now. + +
+
+ Check your email inbox for a verification link. + Send verification email again. + +
diff --git a/src/index.html b/src/index.html index 8bf9e5b9..220de1be 100644 --- a/src/index.html +++ b/src/index.html @@ -152,6 +152,7 @@ +