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:
parent
ed714794fc
commit
7412ff4da7
|
@ -160,6 +160,12 @@ export default DiscourseController.extend(ModalFunctionality, {
|
|||
this.set('authenticate', null);
|
||||
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
|
||||
if (options.authenticated) {
|
||||
if (window.location.pathname === Discourse.getURL('/login')) {
|
||||
|
|
|
@ -53,6 +53,7 @@ class Admin::UsersController < Admin::AdminController
|
|||
@user.suspended_at = DateTime.now
|
||||
@user.save!
|
||||
StaffActionLogger.new(current_user).log_user_suspend(@user, params[:reason])
|
||||
MessageBus.publish "/logout", @user.id, user_ids: [@user.id]
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
|
|
|
@ -19,12 +19,20 @@ class Auth::Result
|
|||
if requires_invite
|
||||
{ requires_invite: true }
|
||||
elsif user
|
||||
{
|
||||
authenticated: !!authenticated,
|
||||
awaiting_activation: !!awaiting_activation,
|
||||
awaiting_approval: !!awaiting_approval,
|
||||
not_allowed_from_ip_address: !!not_allowed_from_ip_address
|
||||
}
|
||||
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,
|
||||
awaiting_activation: !!awaiting_activation,
|
||||
awaiting_approval: !!awaiting_approval,
|
||||
not_allowed_from_ip_address: !!not_allowed_from_ip_address
|
||||
}
|
||||
end
|
||||
else
|
||||
{
|
||||
email: email,
|
||||
|
|
Loading…
Reference in New Issue