From a52d2f4b7a9723b1f78bb0cacadf12fa369ca96a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 14 Nov 2016 23:31:54 -0500 Subject: [PATCH] added account recovery page --- src/Web/wwwroot/_references.js | 1 + .../app/accounts/accountsRecoverController.js | 21 ++++++++ .../views/accountsLoginTwoFactor.html | 5 +- .../app/accounts/views/accountsRecover.html | 52 +++++++++++++++++++ src/Web/wwwroot/app/config.js | 9 ++++ src/Web/wwwroot/app/services/apiService.js | 1 + src/Web/wwwroot/index.html | 1 + 7 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/Web/wwwroot/app/accounts/accountsRecoverController.js create mode 100644 src/Web/wwwroot/app/accounts/views/accountsRecover.html diff --git a/src/Web/wwwroot/_references.js b/src/Web/wwwroot/_references.js index d148fa59c3..a3275034c6 100644 --- a/src/Web/wwwroot/_references.js +++ b/src/Web/wwwroot/_references.js @@ -4,6 +4,7 @@ /// /// /// +/// /// /// /// diff --git a/src/Web/wwwroot/app/accounts/accountsRecoverController.js b/src/Web/wwwroot/app/accounts/accountsRecoverController.js new file mode 100644 index 0000000000..527e512f44 --- /dev/null +++ b/src/Web/wwwroot/app/accounts/accountsRecoverController.js @@ -0,0 +1,21 @@ +angular + .module('bit.accounts') + + .controller('accountsRecoverController', function ($scope, apiService, cryptoService) { + $scope.success = false; + + $scope.submit = function (model) { + var email = model.email.toLowerCase(); + var key = cryptoService.makeKey(model.masterPassword, email); + + var request = { + email: email, + masterPasswordHash: cryptoService.hashPassword(model.masterPassword, key), + recoveryCode: model.code.replace(/\s/g, '').toLowerCase() + }; + + $scope.submitPromise = apiService.accounts.postTwoFactorRecover(request, function () { + $scope.success = true; + }).$promise; + }; + }); diff --git a/src/Web/wwwroot/app/accounts/views/accountsLoginTwoFactor.html b/src/Web/wwwroot/app/accounts/views/accountsLoginTwoFactor.html index 55401e7082..7c31a10680 100644 --- a/src/Web/wwwroot/app/accounts/views/accountsLoginTwoFactor.html +++ b/src/Web/wwwroot/app/accounts/views/accountsLoginTwoFactor.html @@ -13,7 +13,10 @@
-
+ +
diff --git a/src/Web/wwwroot/app/accounts/views/accountsRecover.html b/src/Web/wwwroot/app/accounts/views/accountsRecover.html new file mode 100644 index 0000000000..3cf9d872b4 --- /dev/null +++ b/src/Web/wwwroot/app/accounts/views/accountsRecover.html @@ -0,0 +1,52 @@ + diff --git a/src/Web/wwwroot/app/config.js b/src/Web/wwwroot/app/config.js index d235987baa..31eb338198 100644 --- a/src/Web/wwwroot/app/config.js +++ b/src/Web/wwwroot/app/config.js @@ -105,6 +105,15 @@ angular bodyClass: 'login-page' } }) + .state('frontend.recover', { + url: '^/recover', + templateUrl: 'app/accounts/views/accountsRecover.html', + controller: 'accountsRecoverController', + data: { + pageTitle: 'Recover Account', + bodyClass: 'login-page' + } + }) .state('frontend.register', { url: '^/register', templateUrl: 'app/accounts/views/accountsRegister.html', diff --git a/src/Web/wwwroot/app/services/apiService.js b/src/Web/wwwroot/app/services/apiService.js index 64f496d8eb..b575f7d302 100644 --- a/src/Web/wwwroot/app/services/apiService.js +++ b/src/Web/wwwroot/app/services/apiService.js @@ -38,6 +38,7 @@ putProfile: { url: _apiUri + '/accounts/profile', method: 'POST', params: {} }, getTwoFactor: { url: _apiUri + '/accounts/two-factor', method: 'GET', params: {} }, putTwoFactor: { url: _apiUri + '/accounts/two-factor', method: 'POST', params: {} }, + postTwoFactorRecover: { url: _apiUri + '/accounts/two-factor-recover', method: 'POST', params: {} }, postPasswordHint: { url: _apiUri + '/accounts/password-hint', method: 'POST', params: {} }, putSecurityStamp: { url: _apiUri + '/accounts/security-stamp', method: 'POST', params: {} }, 'import': { url: _apiUri + '/accounts/import', method: 'POST', params: {} }, diff --git a/src/Web/wwwroot/index.html b/src/Web/wwwroot/index.html index b4a80a2f45..24a3585b70 100644 --- a/src/Web/wwwroot/index.html +++ b/src/Web/wwwroot/index.html @@ -110,6 +110,7 @@ +