diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6 index f405e6ee1b1..8e6c722c6ab 100644 --- a/app/assets/javascripts/discourse/controllers/login.js.es6 +++ b/app/assets/javascripts/discourse/controllers/login.js.es6 @@ -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')) { diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index e62999fe019..c0f24695246 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -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 diff --git a/lib/auth/result.rb b/lib/auth/result.rb index 3b0a36b5de5..505541ea4ca 100644 --- a/lib/auth/result.rb +++ b/lib/auth/result.rb @@ -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,