mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 12:27:32 +08:00
FEATURE: staff can block users, which prevents them from creating topics and replies
This commit is contained in:
parent
0dec98f50a
commit
12790d8dcc
|
@ -264,6 +264,7 @@ const AdminUser = Discourse.User.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
unblock() {
|
unblock() {
|
||||||
|
this.set('blockingUser', true);
|
||||||
return Discourse.ajax('/admin/users/' + this.id + '/unblock', {
|
return Discourse.ajax('/admin/users/' + this.id + '/unblock', {
|
||||||
type: 'PUT'
|
type: 'PUT'
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
|
@ -275,14 +276,33 @@ const AdminUser = Discourse.User.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
block() {
|
block() {
|
||||||
return Discourse.ajax('/admin/users/' + this.id + '/block', {
|
const user = this,
|
||||||
type: 'PUT'
|
message = I18n.t("admin.user.block_confirm");
|
||||||
}).then(function() {
|
|
||||||
window.location.reload();
|
const performBlock = function() {
|
||||||
}).catch(function(e) {
|
user.set('blockingUser', true);
|
||||||
var error = I18n.t('admin.user.block_failed', { error: "http: " + e.status + " - " + e.body });
|
return Discourse.ajax('/admin/users/' + user.id + '/block', {
|
||||||
bootbox.alert(error);
|
type: 'PUT'
|
||||||
});
|
}).then(function() {
|
||||||
|
window.location.reload();
|
||||||
|
}).catch(function(e) {
|
||||||
|
var error = I18n.t('admin.user.block_failed', { error: "http: " + e.status + " - " + e.body });
|
||||||
|
bootbox.alert(error);
|
||||||
|
user.set('blockingUser', false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttons = [{
|
||||||
|
"label": I18n.t("composer.cancel"),
|
||||||
|
"class": "cancel",
|
||||||
|
"link": true
|
||||||
|
}, {
|
||||||
|
"label": '<i class="fa fa-exclamation-triangle"></i>' + I18n.t('admin.user.block_accept'),
|
||||||
|
"class": "btn btn-danger",
|
||||||
|
"callback": function() { performBlock(); }
|
||||||
|
}];
|
||||||
|
|
||||||
|
bootbox.dialog(message, buttons, { "classes": "delete-user-modal" });
|
||||||
},
|
},
|
||||||
|
|
||||||
sendActivationEmail() {
|
sendActivationEmail() {
|
||||||
|
|
|
@ -327,13 +327,21 @@
|
||||||
<div class='field'>{{i18n 'admin.user.blocked'}}</div>
|
<div class='field'>{{i18n 'admin.user.blocked'}}</div>
|
||||||
<div class='value'>{{model.blocked}}</div>
|
<div class='value'>{{model.blocked}}</div>
|
||||||
<div class='controls'>
|
<div class='controls'>
|
||||||
{{#if model.blocked}}
|
{{#conditional-loading-spinner size="small" condition=model.blockingUser}}
|
||||||
<button class='btn' {{action "unblock" target="content"}}>
|
{{#if model.blocked}}
|
||||||
{{fa-icon "thumbs-o-up"}}
|
<button class='btn' {{action "unblock" target="content"}}>
|
||||||
{{i18n 'admin.user.unblock'}}
|
{{fa-icon "thumbs-o-up"}}
|
||||||
</button>
|
{{i18n 'admin.user.unblock'}}
|
||||||
{{i18n 'admin.user.block_explanation'}}
|
</button>
|
||||||
{{/if}}
|
{{i18n 'admin.user.block_explanation'}}
|
||||||
|
{{else}}
|
||||||
|
<button class='btn' {{action "block" target="content"}}>
|
||||||
|
{{fa-icon "ban"}}
|
||||||
|
{{i18n 'admin.user.block'}}
|
||||||
|
</button>
|
||||||
|
{{i18n 'admin.user.block_explanation'}}
|
||||||
|
{{/if}}
|
||||||
|
{{/conditional-loading-spinner}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -2448,6 +2448,8 @@ en:
|
||||||
deactivate_failed: "There was a problem deactivating the user."
|
deactivate_failed: "There was a problem deactivating the user."
|
||||||
unblock_failed: 'There was a problem unblocking the user.'
|
unblock_failed: 'There was a problem unblocking the user.'
|
||||||
block_failed: 'There was a problem blocking the user.'
|
block_failed: 'There was a problem blocking the user.'
|
||||||
|
block_confirm: 'Are you sure you want to block this user? They will not be able to create any new topics or posts.'
|
||||||
|
block_accept: 'Yes, block this user'
|
||||||
deactivate_explanation: "A deactivated user must re-validate their email."
|
deactivate_explanation: "A deactivated user must re-validate their email."
|
||||||
suspended_explanation: "A suspended user can't log in."
|
suspended_explanation: "A suspended user can't log in."
|
||||||
block_explanation: "A blocked user can't post or start topics."
|
block_explanation: "A blocked user can't post or start topics."
|
||||||
|
|
Loading…
Reference in New Issue
Block a user