Claim address page security improvements

-Removed the ability to claim an address that has 0 transactions
-The "Claim" button is now disabled after submitting to help prevent double submissions
This commit is contained in:
Joe Uhren
2024-03-20 19:36:16 -06:00
parent cf9dce3449
commit 9c57b4b37a
2 changed files with 42 additions and 29 deletions
+36 -29
View File
@@ -460,35 +460,42 @@ module.exports = {
}, },
update_claim_name: function(hash, claim_name, cb) { update_claim_name: function(hash, claim_name, cb) {
// check if the claim name is being removed // check if the address has received coins before by looking up the address in the local database
if (claim_name == null || claim_name == '') { module.exports.get_address(hash, false, function(address) {
// remove the claim name // check if the address was found in the local database
ClaimAddress.findOneAndDelete({a_id: hash}).then(() => { if (address) {
// run processes after the claim name has been updated // check if the claim name is being removed
after_update_claim_name(hash, claim_name, function() { if (claim_name == null || claim_name == '') {
return cb(''); // remove the claim name
}); ClaimAddress.findOneAndDelete({a_id: hash}).then(() => {
}).catch((err) => { // run processes after the claim name has been updated
console.log(err); after_update_claim_name(hash, claim_name, function() {
return cb(err); return cb('');
}); });
} else { }).catch((err) => {
// add or update the claim name console.log(err);
ClaimAddress.updateOne({a_id: hash}, { return cb(err);
a_id: hash, });
claim_name: claim_name } else {
}, { // add or update the claim name
upsert: true ClaimAddress.updateOne({a_id: hash}, {
}).then(() => { a_id: hash,
// run processes after the claim name has been updated claim_name: claim_name
after_update_claim_name(hash, claim_name, function() { }, {
return cb(''); upsert: true
}); }).then(() => {
}).catch((err) => { // run processes after the claim name has been updated
console.log(err); after_update_claim_name(hash, claim_name, function() {
return cb(err); return cb('');
}); });
} }).catch((err) => {
console.log(err);
return cb(err);
});
}
} else
return cb('no_address');
});
}, },
update_richlist_claim_name: function(hash, claim_name, cb) { update_richlist_claim_name: function(hash, claim_name, cb) {
+6
View File
@@ -47,6 +47,8 @@ block content
) { ) {
showClaimAlert('warning', 'The captcha validation has not been set', false); showClaimAlert('warning', 'The captcha validation has not been set', false);
} else { } else {
$('button.btn-success').attr('disabled', true);
if ('#{selected_captcha_name}' == 'google_recaptcha2' && '#{settings.captcha.google_recaptcha2.captcha_type}' == 'invisible') { if ('#{selected_captcha_name}' == 'google_recaptcha2' && '#{settings.captcha.google_recaptcha2.captcha_type}' == 'invisible') {
grecaptcha.execute(); grecaptcha.execute();
} else if ('#{selected_captcha_name}' == 'google_recaptcha3') { } else if ('#{selected_captcha_name}' == 'google_recaptcha3') {
@@ -117,6 +119,8 @@ block content
// clear out the captcha to allow the form to be submitted again // clear out the captcha to allow the form to be submitted again
grecaptcha.reset(); grecaptcha.reset();
} }
$('button.btn-success').attr('disabled', false);
}); });
} }
function onSubmit(token) { function onSubmit(token) {
@@ -124,6 +128,8 @@ block content
// ensure the onSubmit event can fire again without needing to reload the page in the event that the server returns an error and the form must be submitted again // ensure the onSubmit event can fire again without needing to reload the page in the event that the server returns an error and the form must be submitted again
grecaptcha.reset(); grecaptcha.reset();
$('button.btn-success').attr('disabled', false);
} }
.col-xs-12.col-md-12 .col-xs-12.col-md-12
if settings.claim_address_page.page_header.show_img == true || settings.claim_address_page.page_header.show_title == true || settings.claim_address_page.page_header.show_description == true if settings.claim_address_page.page_header.show_img == true || settings.claim_address_page.page_header.show_title == true || settings.claim_address_page.page_header.show_description == true