From 548942a6d515e9f5824a28212d358fc8354c9ec5 Mon Sep 17 00:00:00 2001 From: Ivan Tivonenko Date: Tue, 17 Feb 2015 02:36:56 +0200 Subject: [PATCH] [FIX] Resend email without unlock (RT-3104) Sign-up: resend email without requiring unlock --- src/js/services/id.js | 7 +++++ src/js/tabs/register.js | 57 +++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/js/services/id.js b/src/js/services/id.js index 943cf6b06..440bbf035 100644 --- a/src/js/services/id.js +++ b/src/js/services/id.js @@ -430,6 +430,13 @@ module.factory('rpId', ['$rootScope', '$location', '$route', '$routeParams', '$t if (!emailVerified) { $scope.unverified = true; + // get secret to allow email re-send without unlocking + $authflow.unlock(Id.normalizeUsernameForInternals(username), password, function(err, resp) { + if (!err && resp) { + $scope.keyOpen = resp.secret; + } + }); + $location.path('/register'); callback(new Error("Email has not been verified!")); diff --git a/src/js/tabs/register.js b/src/js/tabs/register.js index 368ac65e4..0e7381701 100644 --- a/src/js/tabs/register.js +++ b/src/js/tabs/register.js @@ -137,39 +137,46 @@ RegisterTab.prototype.angular = function (module) { }); }; + var _resnedEmail = function(masterkey) { + id.resendEmail({ + id:$scope.userBlob.id, + url:$scope.userBlob.url, + username: $scope.userCredentials.username, + account_id: $scope.userBlob.data.account_id, + email: $scope.newEmail || $scope.userBlob.data.email, + masterkey: masterkey + }, function(err, response){ + if (err) { + console.log('Error', err); + return; + } + + // Update the blob + $scope.userBlob.set('/email', $scope.newEmail || $scope.userBlob.data.email); + + $scope.resendLoading = false; + $scope.resendSuccess = true; + }); + } + $scope.resendEmail = function() { $scope.resendLoading = true; - keychain.requestSecret(id.account, id.username, - function (err, masterkey) { - if (err) { - console.log('client: register tab: error while ' + - 'unlocking wallet: ', err); - $scope.mode = 'verification'; - return; - } - - id.resendEmail({ - id:$scope.userBlob.id, - url:$scope.userBlob.url, - username: $scope.userCredentials.username, - account_id: $scope.userBlob.data.account_id, - email: $scope.newEmail || $scope.userBlob.data.email, - masterkey: masterkey - }, function(err, response){ + if ($scope.keyOpen) { + _resnedEmail($scope.keyOpen); + } else { + keychain.requestSecret(id.account, id.username, + function (err, masterkey) { if (err) { - console.log('Error', err); + console.log('client: register tab: error while ' + + 'unlocking wallet: ', err); + $scope.mode = 'verification'; return; } - - // Update the blob - $scope.userBlob.set('/email', $scope.newEmail || $scope.userBlob.data.email); - - $scope.resendLoading = false; - $scope.resendSuccess = true; + _resnedEmail(masterkey); }); - }); + } }; var updateFormFields = function() {