verify email

This commit is contained in:
Kyle Spearrin 2017-07-05 15:36:40 -04:00
parent 5d81ed6a96
commit b24f892f60
8 changed files with 74 additions and 9 deletions

View File

@ -42,8 +42,4 @@ angular
$scope.loading = false; $scope.loading = false;
} }
}); });
$scope.submit = function (model) {
};
}); });

View File

@ -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');
});
});
});
});

View File

@ -0,0 +1,8 @@
<div class="login-box">
<div class="login-logo">
<i class="fa fa-shield"></i> <b>bit</b>warden
</div>
<div class="login-box-body">
Verifying email...
</div>
</div>

View File

@ -7,7 +7,7 @@ angular
$locationProvider.hashPrefix(''); $locationProvider.hashPrefix('');
jwtOptionsProvider.config({ jwtOptionsProvider.config({
urlParam: 'access_token3', 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; var refreshPromise;
jwtInterceptorProvider.tokenGetter = /*@ngInject*/ function (options, tokenService, authService) { jwtInterceptorProvider.tokenGetter = /*@ngInject*/ function (options, tokenService, authService) {
@ -260,6 +260,16 @@ angular
bodyClass: 'login-page', bodyClass: 'login-page',
skipAuthorize: true 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) { .run(function ($rootScope, authService, $state) {

View File

@ -2,7 +2,7 @@ angular
.module('bit.global') .module('bit.global')
.controller('mainController', function ($scope, $state, authService, appSettings, toastr, $window, $document, .controller('mainController', function ($scope, $state, authService, appSettings, toastr, $window, $document,
cryptoService, $uibModal) { cryptoService, $uibModal, apiService) {
var vm = this; var vm = this;
vm.bodyClass = ''; vm.bodyClass = '';
vm.usingControlSidebar = vm.openControlSidebar = false; vm.usingControlSidebar = vm.openControlSidebar = false;
@ -79,7 +79,19 @@ angular
}; };
$scope.verifyEmail = function () { $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 // Append dropdown menu somewhere else

View File

@ -104,6 +104,8 @@
register: { url: _apiUri + '/accounts/register', method: 'POST', params: {} }, register: { url: _apiUri + '/accounts/register', method: 'POST', params: {} },
emailToken: { url: _apiUri + '/accounts/email-token', method: 'POST', params: {} }, emailToken: { url: _apiUri + '/accounts/email-token', method: 'POST', params: {} },
email: { url: _apiUri + '/accounts/email', 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: {} }, putPassword: { url: _apiUri + '/accounts/password', method: 'POST', params: {} },
getProfile: { url: _apiUri + '/accounts/profile', method: 'GET', params: {} }, getProfile: { url: _apiUri + '/accounts/profile', method: 'GET', params: {} },
putProfile: { url: _apiUri + '/accounts/profile', method: 'POST', params: {} }, putProfile: { url: _apiUri + '/accounts/profile', method: 'POST', params: {} },

View File

@ -144,8 +144,16 @@
<div class="alert alert-warning alert-notification" ng-click="verifyEmail()" <div class="alert alert-warning alert-notification" ng-click="verifyEmail()"
ng-if="main.usingEncKey && main.userProfile && !main.userProfile.emailVerified"> ng-if="main.usingEncKey && main.userProfile && !main.userProfile.emailVerified">
<h4><i class="fa fa-envelope fa-fw"></i> Verify Your Email</h4> <h4><i class="fa fa-envelope fa-fw"></i> Verify Your Email</h4>
Verify your account's email address to unlock access to all features. <div ng-if="!verifyEmailSent">
<a href="#" stop-click>Send verification email now</a>. Verify your account's email address to unlock access to all features.
<a href="#" stop-click>Send verification email now</a>.
<i class="fa fa-spin fa-refresh" ng-if="sendingVerify"></i>
</div>
<div ng-if="verifyEmailSent">
Check your email inbox for a verification link.
<a href="#" stop-click>Send verification email again</a>.
<i class="fa fa-spin fa-refresh" ng-if="sendingVerify"></i>
</div>
</div> </div>
<div ui-view></div> <div ui-view></div>
</div> </div>

View File

@ -152,6 +152,7 @@
<script src="app/accounts/accountsRecoverController.js"></script> <script src="app/accounts/accountsRecoverController.js"></script>
<script src="app/accounts/accountsOrganizationAcceptController.js"></script> <script src="app/accounts/accountsOrganizationAcceptController.js"></script>
<script src="app/accounts/accountsTwoFactorMethodsController.js"></script> <script src="app/accounts/accountsTwoFactorMethodsController.js"></script>
<script src="app/accounts/accountsVerifyEmailController.js"></script>
<script src="app/vault/vaultModule.js"></script> <script src="app/vault/vaultModule.js"></script>
<script src="app/vault/vaultController.js"></script> <script src="app/vault/vaultController.js"></script>