Skip to content

Commit

Permalink
fix(recover): remove catpcha from aes.json recover flow
Browse files Browse the repository at this point in the history
  • Loading branch information
schnogz committed Jun 9, 2021
1 parent 5c7598c commit b420fbe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 104 deletions.
22 changes: 0 additions & 22 deletions legacy-pages/import-wallet.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,6 @@ <h3>Choose a New Password</h3>
</div>
</div>
</div>
<div id="kaptcha-modal" class="modal hide">
<div class="modal-dialog">
<div class="modal-header bg-white">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Verify You Are Human</h3>
</div>
<div class="modal-body bg-white">
<p>Please enter the captcha code below.</p>
<p align="center">
<img id="captcha"/>
</p>
<p align="center">
<input type="text" id="captcha-value" value="" size="10" style="float:none;width:200px;min-width:200px" />
</p>
</div>
<div class="modal-footer bg-white">
<div class="btn-group">
<button class="btn btn-primary">Continue</button>
</div>
</div>
</div>
</div>
<div id="main-notices-container" style="margin:0 auto; width:auto; min-width:280px;">
<span id="notices" style="max-width: 600px; width:100%;"></span>
</div>
Expand Down
117 changes: 35 additions & 82 deletions legacy-pages/js/import/wallet-import.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
(function() {
//Save the javascript wallet to the remote server
function reallyInsertWallet(guid, sharedKey, password, extra, successcallback, errorcallback) {
function reallyInsertWallet(guid, sharedKey, password, successcallback) {
var _errorcallback = function(e) {
MyWallet.makeNotice('error', 'misc-error', 'Error Saving Wallet: ' + e, 10000);

if (errorcallback != null)
errorcallback(e);
else throw e;
throw e;
};

try {
Expand All @@ -27,10 +24,7 @@

MyWallet.setLoadingText('Saving wallet');

if (extra == null)
extra = '';

MyWallet.securePost('wallet' + extra, { length: crypted.length, payload: crypted, checksum: new_checksum, method : 'insert', format : 'plain', sharedKey : sharedKey, guid : guid }, function(data) {
MyWallet.securePost('wallet', { length: crypted.length, payload: crypted, checksum: new_checksum, method : 'insert', format : 'plain', sharedKey : sharedKey, guid : guid }, function(data) {
MyWallet.makeNotice('success', 'misc-success', data);

if (successcallback != null)
Expand All @@ -48,15 +42,14 @@
}
}

function uploadWallet(url, file, success, error, password, kaptcha) {
function uploadWallet(url, file, success, error, password) {

$('.loading-indicator').fadeIn(200);

var formData = new FormData();

formData.append('file', file);
formData.append('password', password);
formData.append('kaptcha', kaptcha);

var xhr = new XMLHttpRequest();

Expand All @@ -83,40 +76,6 @@
xhr.send(formData); // multipart/form-data
}

function showKaptchaModal(success) {
var modal = $('#kaptcha-modal');

$('#captcha-value').val('');

$("#captcha").attr("src", root + "kaptcha.jpg?timestamp=" + new Date().getTime());

modal.modal({
keyboard: true,
backdrop: "static",
show: true
});

//Center
modal.center();

modal.find('.btn.btn-primary').unbind().click(function() {
modal.modal('hide');

var code = $.trim($('#captcha-value').val());

if (code.length == 0) {
MyWallet.makeNotice('error', 'misc-error', 'You must enter a captcha code');
return;
}

success(code);
});

modal.find('.btn.btn-secondary').unbind().click(function() {
modal.modal('hide');
});
}

function getNewPassword(success) {

var modal = $('#new-password-modal');
Expand Down Expand Up @@ -180,33 +139,29 @@

function insertWallet() {
getNewPassword(function(password) {
showKaptchaModal(function(kaptcha) {
generateUUIDs(2, function(uuids) {
try {
var guid = uuids[0];
var sharedKey = uuids[1];
generateUUIDs(2, function(uuids) {
try {
var guid = uuids[0];
var sharedKey = uuids[1];

if (guid.length != 36) {
throw 'Error generating wallet identifier';
}
if (guid.length != 36) {
throw 'Error generating wallet identifier';
}

reallyInsertWallet(guid, sharedKey, password, '?kaptcha='+ $.trim($('#captcha-value').val()), function(){
MyStore.clear();
reallyInsertWallet(guid, sharedKey, password, function(){
MyStore.clear();

MyStore.put('guid', guid);
MyStore.put('guid', guid);

window.confirm(`Your wallet has been recovered successfully! \n\nIMPORTANT: Copy your new Wallet ID below and use it, along with your new password, to login on the next page. \n\n${guid}`)
window.confirm(`Your wallet has been recovered successfully! You will now be redirected to the login page with your new wallet ID prefilled. Use the password you created to login into your wallet.`)

window.location = root + 'wallet/login/' + guid;
}, function() {
$("#captcha").attr("src", root + "kaptcha.jpg?timestamp=" + new Date().getTime());
});
} catch (e) {
MyWallet.makeNotice('error', 'misc-error', e);
}
}, function(error) {
console.error(error)
});
window.location = 'https://login.blockchain.com/#/login/' + guid;
});
} catch (e) {
MyWallet.makeNotice('error', 'misc-error', e);
}
}, function(error) {
console.error(error)
});
});
}
Expand Down Expand Up @@ -249,24 +204,22 @@

return;
} else if (f.name.indexOf('.dat') == f.name.length - 4) {
showKaptchaModal(function(kaptcha) {
MyWallet.getPassword($('#import-password-modal'), function(password) {
uploadWallet(root + 'upload_wallet', f, function(response) {
$('.loading-indicator').fadeIn(200);
MyWallet.getPassword($('#import-password-modal'), function(password) {
uploadWallet(root + 'upload_wallet', f, function(response) {
$('.loading-indicator').fadeIn(200);

ImportExport.importJSON(response, {}, function() {
$('.loading-indicator').fadeOut(200);
ImportExport.importJSON(response, {}, function() {
$('.loading-indicator').fadeOut(200);

insertWallet();
}, function(e) {
$('.loading-indicator').fadeOut(200);
insertWallet();
}, function(e) {
$('.loading-indicator').fadeOut(200);

MyWallet.makeNotice('error', 'misc-error', e);
});
}, function(response) {
MyWallet.makeNotice('error', 'misc-error', response);
}, password, kaptcha);
});
MyWallet.makeNotice('error', 'misc-error', e);
});
}, function(response) {
MyWallet.makeNotice('error', 'misc-error', response);
}, password);
});
} else {
MyWallet.makeNotice('error', 'misc-error', 'Unknown File Type ' + f.name);
Expand Down

0 comments on commit b420fbe

Please sign in to comment.