mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: suspended users are logged out when they are suspended. Show a reason for suspension when they try to log in.
This commit is contained in:
@ -160,6 +160,12 @@ export default DiscourseController.extend(ModalFunctionality, {
|
|||||||
this.set('authenticate', null);
|
this.set('authenticate', null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (options.suspended) {
|
||||||
|
this.send('showLogin');
|
||||||
|
this.flash(options.suspended_message, 'error');
|
||||||
|
this.set('authenticate', null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Reload the page if we're authenticated
|
// Reload the page if we're authenticated
|
||||||
if (options.authenticated) {
|
if (options.authenticated) {
|
||||||
if (window.location.pathname === Discourse.getURL('/login')) {
|
if (window.location.pathname === Discourse.getURL('/login')) {
|
||||||
|
@ -53,6 +53,7 @@ class Admin::UsersController < Admin::AdminController
|
|||||||
@user.suspended_at = DateTime.now
|
@user.suspended_at = DateTime.now
|
||||||
@user.save!
|
@user.save!
|
||||||
StaffActionLogger.new(current_user).log_user_suspend(@user, params[:reason])
|
StaffActionLogger.new(current_user).log_user_suspend(@user, params[:reason])
|
||||||
|
MessageBus.publish "/logout", @user.id, user_ids: [@user.id]
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,12 +19,20 @@ class Auth::Result
|
|||||||
if requires_invite
|
if requires_invite
|
||||||
{ requires_invite: true }
|
{ requires_invite: true }
|
||||||
elsif user
|
elsif user
|
||||||
|
if user.suspended?
|
||||||
|
{
|
||||||
|
suspended: true,
|
||||||
|
suspended_message: I18n.t( user.suspend_reason ? "login.suspended_with_reason" : "login.suspended",
|
||||||
|
{date: I18n.l(user.suspended_till, format: :date_only), reason: user.suspend_reason} )
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
authenticated: !!authenticated,
|
authenticated: !!authenticated,
|
||||||
awaiting_activation: !!awaiting_activation,
|
awaiting_activation: !!awaiting_activation,
|
||||||
awaiting_approval: !!awaiting_approval,
|
awaiting_approval: !!awaiting_approval,
|
||||||
not_allowed_from_ip_address: !!not_allowed_from_ip_address
|
not_allowed_from_ip_address: !!not_allowed_from_ip_address
|
||||||
}
|
}
|
||||||
|
end
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
email: email,
|
email: email,
|
||||||
|
Reference in New Issue
Block a user