Skip to content

Commit 1801e96

Browse files
authored
Merge pull request #1850 from codidact/0valt/1813/logout-visibility
Sign out button visibility & suspension check fix
2 parents ed53ac1 + ed021f2 commit 1801e96

7 files changed

Lines changed: 229 additions & 233 deletions

File tree

app/controllers/admin_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class AdminController < ApplicationController
66
before_action :verify_developer, only: [:change_users, :impersonate]
77
before_action :set_user, only: [:change_users, :hellban, :impersonate]
88

9+
skip_before_action :check_if_warning_or_suspension_pending, only: [:change_back, :verify_elevation]
10+
911
def index; end
1012

1113
def error_reports

app/controllers/application_controller.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
88
before_action :configure_permitted_parameters, if: :devise_controller?
99
before_action :set_globals
1010
before_action :enforce_signed_in, unless: :devise_controller?
11-
before_action :check_if_warning_or_suspension_pending
11+
before_action :check_if_warning_or_suspension_pending, if: [:user_signed_in?], unless: [:devise_controller?]
1212
before_action :distinguish_fake_community
1313
before_action :stop_the_awful_troll
1414

@@ -272,13 +272,7 @@ def pull_categories
272272
end
273273

274274
def check_if_warning_or_suspension_pending
275-
return if current_user.nil?
276-
277-
warning = ModWarning.to(current_user).active.any?
278-
return unless warning
279-
280-
# Ignore devise and warning routes
281-
return if devise_controller? || ['custom_sessions', 'mod_warning', 'errors'].include?(controller_name)
275+
return unless ModWarning.to(current_user).active.any?
282276

283277
flash.clear
284278

app/controllers/errors_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Note that it requires +consider_all_requests_local+ to be +false+ (see environment config files for details)
44
class ErrorsController < ApplicationController
55
protect_from_forgery with: :exception, except: [:error], store: :cookie
6+
skip_before_action :check_if_warning_or_suspension_pending, only: [:error]
67

78
def error
89
@exception = request.env['action_dispatch.exception']

app/controllers/mod_warning_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
class ModWarningController < ApplicationController
22
before_action :verify_moderator, only: [:log, :new, :create, :lift]
3-
43
before_action :set_warning, only: [:current, :approve]
54
before_action :set_user, only: [:log, :new, :create, :lift]
65

6+
skip_before_action :check_if_warning_or_suspension_pending, only: [:current, :approve]
7+
78
def current
89
render layout: 'without_sidebar'
910
end

0 commit comments

Comments
 (0)