Skip to content

Node.js based forum software built for the modern web

closes #3258

barisusaklia31178ebd87b
diff --git a/public/language/en_GB/user.json b/public/language/en_GB/user.json
index 99f118ad5a..73d2b6784c 100644
--- a/public/language/en_GB/user.json
+++ b/public/language/en_GB/user.json
@@ -7,8 +7,12 @@
"email": "Email",
"confirm_email": "Confirm Email",
+ "ban_account": "Ban Account",
+ "ban_account_confirm": "Do you really want to ban this user?",
+ "unban_account": "Unban Account",
"delete_account": "Delete Account",
"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 username to confirm that you wish to destroy this account.",
+ "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 />",
"fullname": "Full Name",
"website": "Website",
diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js
index 00be98d99f..daf602d81d 100644
--- a/public/src/client/account/profile.js
+++ b/public/src/client/account/profile.js
@@ -1,6 +1,6 @@
'use strict';
-/* globals define, ajaxify, app, utils, socket */
+/* globals define, ajaxify, app, utils, socket, bootbox */
define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll', 'translator'], function(header, infinitescroll, translator) {
var Account = {},
@@ -33,6 +33,10 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
app.openChat($('.account-username').html(), theirid);
});
+ $('#banAccountBtn').on('click', banAccount);
+ $('#unbanAccountBtn').on('click', unbanAccount);
+ $('#deleteAccountBtn').on('click', deleteAccount);
+
socket.removeListener('event:user_status_change', onUserStatusChange);
socket.on('event:user_status_change', onUserStatusChange);
@@ -112,5 +116,49 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
});
}
+ function banAccount() {
+ translator.translate('[[user:ban_account_confirm]]', function(translated) {
+ bootbox.confirm(translated, function(confirm) {
+ if (!confirm) {
+ return;
+ }
+ socket.emit('admin.user.banUsers', [ajaxify.variables.get('theirid')], function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ $('#banAccountBtn').toggleClass('hide', true);
+ $('#banLabel, #unbanAccountBtn').toggleClass('hide', false);
+ });
+ });
+ });
+ }
+
+ function unbanAccount() {
+ socket.emit('admin.user.unbanUsers', [ajaxify.variables.get('theirid')], function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ $('#banAccountBtn').toggleClass('hide', false);
+ $('#banLabel, #unbanAccountBtn').toggleClass('hide', true);
+ });
+ }
+
+ function deleteAccount() {
+ translator.translate('[[user:delete_this_account_confirm]]', function(translated) {
+ bootbox.confirm(translated, function(confirm) {
+ if (!confirm) {
+ return;
+ }
+
+ socket.emit('admin.user.deleteUsers', [ajaxify.variables.get('theirid')], function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ history.back();
+ });
+ });
+ });
+ }
+
return Account;
});
diff --git a/src/controllers/accounts.js b/src/controllers/accounts.js
index 1fca24aae1..92ae47250f 100644
--- a/src/controllers/accounts.js
+++ b/src/controllers/accounts.js
@@ -80,6 +80,7 @@ function getUserDataByUserSlug(userslug, callerUID, callback) {
userData.uid = userData.uid;
userData.yourid = callerUID;
userData.theirid = userData.uid;
+ userData.isAdmin = isAdmin;
userData.isSelf = self;
userData.showHidden = self || isAdmin;
userData.groups = Array.isArray(results.groups) && results.groups.length ? results.groups[0] : [];