Add a warning when a premium user is deleting their account

pull/1/head
yflory 4 years ago
parent 8afb71cf90
commit 7731cb603f

@ -469,6 +469,10 @@ define([
}); });
}, true); }, true);
Messages.settings_deleteWarning = "Warning: it seems you're subscribed to a premium plan (paid or given by another user). Please cancel paid subscriptions before deleting your account as you won't be able to do it yourself once the account is deleted."; // XXX
Messages.settings_deleteContinue = "Delete my account"; // XXX
Messages.settings_deleteSubscription = "Manage my subscription"; // XXX
makeBlock('delete', function(cb) { // Msg.settings_deleteHint, .settings_deleteTitle makeBlock('delete', function(cb) { // Msg.settings_deleteHint, .settings_deleteTitle
if (!common.isLoggedIn()) { return cb(false); } if (!common.isLoggedIn()) { return cb(false); }
@ -488,7 +492,34 @@ define([
classes: 'btn-danger', classes: 'btn-danger',
multiple: true multiple: true
}, function() { }, function() {
nThen(function (waitFor) {
$button.prop('disabled', 'disabled'); $button.prop('disabled', 'disabled');
var priv = metadataMgr.getPrivateData();
// Check if subscriptions are enabled and you have a premium plan
if (priv.plan && priv.plan !== "custom" && ApiConfig.allowSubscriptions) {
// Also make sure upgradeURL is defined
var url = priv.accounts && priv.accounts.upgradeURL;
if (!url) { return; }
url += '#mysubs';
var a = h('a', { href:url }, Messages.settings_deleteSubscription);
$(a).click(function (e) {
e.preventDefault();
common.openUnsafeURL(url);
});
UI.confirm(h('div', [
Messages.settings_deleteWarning, h('p', a)
]), waitFor(function (yes) {
if (!yes) {
$button.prop('disabled', '');
waitFor.abort();
}
}), {
ok: Messages.settings_deleteContinue,
okClass: 'btn.btn-danger',
cancelClass: 'btn.btn-primary'
});
}
}).nThen(function () {
var password = $form.find('#cp-settings-delete-account').val(); var password = $form.find('#cp-settings-delete-account').val();
if (!password) { if (!password) {
return void UI.warn(Messages.error); return void UI.warn(Messages.error);
@ -525,6 +556,7 @@ define([
$button.prop('disabled', ''); $button.prop('disabled', '');
}); });
}); });
});
cb(form); cb(form);
}, true); }, true);

Loading…
Cancel
Save