mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: #8384 options to delete account, content, or both
This commit is contained in:
@@ -9,14 +9,18 @@
|
|||||||
"email": "Email",
|
"email": "Email",
|
||||||
"confirm_email": "Confirm Email",
|
"confirm_email": "Confirm Email",
|
||||||
"account_info": "Account Info",
|
"account_info": "Account Info",
|
||||||
|
"admin_actions_label": "Administrative Actions",
|
||||||
"ban_account": "Ban Account",
|
"ban_account": "Ban Account",
|
||||||
"ban_account_confirm": "Do you really want to ban this user?",
|
"ban_account_confirm": "Do you really want to ban this user?",
|
||||||
"unban_account": "Unban Account",
|
"unban_account": "Unban Account",
|
||||||
"delete_account": "Delete Account",
|
"delete_account": "Delete Account",
|
||||||
"delete_content": "Delete Account Content Only",
|
"delete_account_as_admin": "Delete <strong>Account</strong>",
|
||||||
"delete_account_confirm": "Are you sure you want to delete your account? <br /><strong>This action is irreversible and you will not be able to recover any of your data</strong><br /><br />Enter your password to confirm that you wish to destroy this account.",
|
"delete_content": "Delete Account <strong>Content</strong>",
|
||||||
"delete_this_account_confirm": "Are you sure you want to delete this account? <br /><strong>This action is irreversible and you will not be able to recover any data</strong><br /><br />",
|
"delete_all": "Delete <strong>Account</strong> and <strong>Content</strong>",
|
||||||
|
"delete_account_confirm": "Are you sure you want to anonymize your posts and delete your account?<br /><strong>This action is irreversible and you will not be able to recover any of your data</strong><br /><br />Enter your password to confirm that you wish to destroy this account.",
|
||||||
|
"delete_this_account_confirm": "Are you sure you want to delete this account while leaving its contents behind?<br /><strong>This action is irreversible, posts will be anonymized, and you will not be able to restore post associations with the deleted account</strong><br /><br />",
|
||||||
"delete_account_content_confirm": "Are you sure you want to delete this account's content (posts/topics/uploads)? <br /><strong>This action is irreversible and you will not be able to recover any data</strong><br /><br />",
|
"delete_account_content_confirm": "Are you sure you want to delete this account's content (posts/topics/uploads)? <br /><strong>This action is irreversible and you will not be able to recover any data</strong><br /><br />",
|
||||||
|
"delete_all_confirm": "Are you sure you want to delete this account and all of its content (posts/topics/uploads)? <br /><strong>This action is irreversible and you will not be able to recover any data</strong><br /><br />",
|
||||||
"account-deleted": "Account deleted",
|
"account-deleted": "Account deleted",
|
||||||
"account-content-deleted": "Account content deleted",
|
"account-content-deleted": "Account content deleted",
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ define('forum/account/header', [
|
|||||||
'components',
|
'components',
|
||||||
'translator',
|
'translator',
|
||||||
'benchpress',
|
'benchpress',
|
||||||
], function (coverPhoto, pictureCropper, components, translator, Benchpress) {
|
'accounts/delete',
|
||||||
|
], function (coverPhoto, pictureCropper, components, translator, Benchpress, AccountsDelete) {
|
||||||
var AccountHeader = {};
|
var AccountHeader = {};
|
||||||
var isAdminOrSelfOrGlobalMod;
|
var isAdminOrSelfOrGlobalMod;
|
||||||
|
|
||||||
@@ -51,15 +52,19 @@ define('forum/account/header', [
|
|||||||
|
|
||||||
components.get('account/ban').on('click', banAccount);
|
components.get('account/ban').on('click', banAccount);
|
||||||
components.get('account/unban').on('click', unbanAccount);
|
components.get('account/unban').on('click', unbanAccount);
|
||||||
components.get('account/delete').on('click', deleteAccount);
|
components.get('account/delete-account').on('click', handleDeleteEvent.bind(null, 'account'));
|
||||||
|
components.get('account/delete-content').on('click', handleDeleteEvent.bind(null, 'content'));
|
||||||
|
components.get('account/delete-all').on('click', handleDeleteEvent.bind(null, 'purge'));
|
||||||
components.get('account/flag').on('click', flagAccount);
|
components.get('account/flag').on('click', flagAccount);
|
||||||
components.get('account/block').on('click', toggleBlockAccount);
|
components.get('account/block').on('click', toggleBlockAccount);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: These exported methods are used in forum/flags/detail -- refactor??
|
function handleDeleteEvent(type) {
|
||||||
|
AccountsDelete[type](ajaxify.data.theirid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This exported method is used in forum/flags/detail -- refactor??
|
||||||
AccountHeader.banAccount = banAccount;
|
AccountHeader.banAccount = banAccount;
|
||||||
AccountHeader.deleteAccount = deleteAccount;
|
|
||||||
AccountHeader.deleteContent = deleteContent;
|
|
||||||
|
|
||||||
function hidePrivateLinks() {
|
function hidePrivateLinks() {
|
||||||
if (!app.user.uid || app.user.uid !== parseInt(ajaxify.data.theirid, 10)) {
|
if (!app.user.uid || app.user.uid !== parseInt(ajaxify.data.theirid, 10)) {
|
||||||
@@ -177,56 +182,6 @@ define('forum/account/header', [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAccount(theirid, onSuccess) {
|
|
||||||
theirid = theirid || ajaxify.data.theirid;
|
|
||||||
|
|
||||||
translator.translate('[[user:delete_this_account_confirm]]', function (translated) {
|
|
||||||
bootbox.confirm(translated, function (confirm) {
|
|
||||||
if (!confirm) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.emit('admin.user.deleteUsersAndContent', [theirid], function (err) {
|
|
||||||
if (err) {
|
|
||||||
return app.alertError(err.message);
|
|
||||||
}
|
|
||||||
app.alertSuccess('[[user:account-deleted]]');
|
|
||||||
|
|
||||||
if (typeof onSuccess === 'function') {
|
|
||||||
return onSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
history.back();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteContent(theirid, onSuccess) {
|
|
||||||
theirid = theirid || ajaxify.data.theirid;
|
|
||||||
|
|
||||||
translator.translate('[[user:delete_account_content_confirm]]', function (translated) {
|
|
||||||
bootbox.confirm(translated, function (confirm) {
|
|
||||||
if (!confirm) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.emit('admin.user.deleteUsersContent', [theirid], function (err) {
|
|
||||||
if (err) {
|
|
||||||
return app.alertError(err.message);
|
|
||||||
}
|
|
||||||
app.alertSuccess('[[user:account-content-deleted]]');
|
|
||||||
|
|
||||||
if (typeof onSuccess === 'function') {
|
|
||||||
return onSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
history.back();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function flagAccount() {
|
function flagAccount() {
|
||||||
require(['flags'], function (flags) {
|
require(['flags'], function (flags) {
|
||||||
flags.showFlagModal({
|
flags.showFlagModal({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'benchpress', 'forum/account/header'], function (FlagsList, components, translator, Benchpress, AccountHeader) {
|
define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'benchpress', 'forum/account/header', 'accounts/delete'], function (FlagsList, components, translator, Benchpress, AccountHeader, AccountsDelete) {
|
||||||
var Detail = {};
|
var Detail = {};
|
||||||
|
|
||||||
Detail.init = function () {
|
Detail.init = function () {
|
||||||
@@ -49,11 +49,15 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete-account':
|
case 'delete-account':
|
||||||
AccountHeader.deleteAccount(uid, ajaxify.refresh);
|
AccountsDelete.account(uid, ajaxify.refresh);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete-content':
|
case 'delete-content':
|
||||||
AccountHeader.deleteContent(uid, ajaxify.refresh);
|
AccountsDelete.content(uid, ajaxify.refresh);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'delete-all':
|
||||||
|
AccountsDelete.purge(uid, ajaxify.refresh);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete-post':
|
case 'delete-post':
|
||||||
|
|||||||
58
public/src/modules/accounts/delete.js
Normal file
58
public/src/modules/accounts/delete.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
define('accounts/delete', [], function () {
|
||||||
|
var Delete = {};
|
||||||
|
|
||||||
|
Delete.account = function (uid, callback) {
|
||||||
|
executeAction(
|
||||||
|
uid,
|
||||||
|
'[[user:delete_this_account_confirm]]',
|
||||||
|
'admin.user.deleteUsers',
|
||||||
|
'[[user:account-deleted]]',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Delete.content = function (uid, callback) {
|
||||||
|
executeAction(
|
||||||
|
uid,
|
||||||
|
'[[user:delete_account_content_confirm]]',
|
||||||
|
'admin.user.deleteUsersContent',
|
||||||
|
'[[user:account-content-deleted]]',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Delete.purge = function (uid, callback) {
|
||||||
|
executeAction(
|
||||||
|
uid,
|
||||||
|
'[[user:delete_all_confirm]]',
|
||||||
|
'admin.user.deleteUsersAndContent',
|
||||||
|
'[[user:account-deleted]]',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function executeAction(uid, confirmText, action, successText, callback) {
|
||||||
|
bootbox.confirm(confirmText, function (confirm) {
|
||||||
|
if (!confirm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.emit(action, [uid], function (err) {
|
||||||
|
if (err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
app.alertSuccess(successText);
|
||||||
|
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
history.back();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Delete;
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user