Просмотр исходного кода

Fixes #3119 - Clarify authentication_check and authorize! before_actions

Mantas 2 лет назад
Родитель
Сommit
3b29835d4a

+ 4 - 0
app/controllers/application_controller/authenticates.rb

@@ -173,4 +173,8 @@ module ApplicationController::Authenticates
   def raise_unified_login_error
     raise Exceptions::NotAuthorized, __('Login failed. Have you double-checked your credentials and completed the email verification step?')
   end
+
+  def authenticate_and_authorize!
+    authentication_check && authorize!
+  end
 end

+ 1 - 1
app/controllers/applications_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class ApplicationsController < ApplicationController
-  prepend_before_action { authentication_check && authorize! }
+  prepend_before_action :authenticate_and_authorize!
 
   def index
     all = Doorkeeper::Application.all

+ 1 - 1
app/controllers/calendars_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class CalendarsController < ApplicationController
-  prepend_before_action { authentication_check && authorize! }
+  prepend_before_action :authenticate_and_authorize!
 
   def init
     assets = {}

+ 1 - 1
app/controllers/channels_email_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class ChannelsEmailController < ApplicationController
-  prepend_before_action { authentication_check && authorize! }
+  prepend_before_action :authenticate_and_authorize!
 
   def index
     system_online_service = Setting.get('system_online_service')

+ 1 - 1
app/controllers/channels_facebook_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class ChannelsFacebookController < ApplicationController
-  prepend_before_action { authentication_check && authorize! }
+  prepend_before_action :authenticate_and_authorize!
 
   def index
     assets = {}

+ 1 - 1
app/controllers/channels_google_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class ChannelsGoogleController < ApplicationController
-  prepend_before_action -> { authentication_check && authorize! }
+  prepend_before_action :authenticate_and_authorize!
 
   def index
     system_online_service = Setting.get('system_online_service')

+ 1 - 1
app/controllers/channels_microsoft365_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class ChannelsMicrosoft365Controller < ApplicationController
-  prepend_before_action -> { authentication_check && authorize! }
+  prepend_before_action :authenticate_and_authorize!
 
   def index
     system_online_service = Setting.get('system_online_service')

+ 1 - 1
app/controllers/channels_sms_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class ChannelsSmsController < ApplicationController
-  prepend_before_action -> { authentication_check && authorize! }, except: [:webhook]
+  prepend_before_action :authenticate_and_authorize!, except: [:webhook]
   skip_before_action :verify_csrf_token, only: [:webhook]
 
   def index

+ 1 - 1
app/controllers/channels_telegram_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class ChannelsTelegramController < ApplicationController
-  prepend_before_action -> { authentication_check && authorize! }, except: [:webhook]
+  prepend_before_action :authenticate_and_authorize!, except: [:webhook]
   skip_before_action :verify_csrf_token, only: [:webhook]
 
   def index

+ 1 - 1
app/controllers/channels_twitter_controller.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class ChannelsTwitterController < ApplicationController
-  prepend_before_action -> { authentication_check && authorize! }, except: %i[webhook_incoming webhook_verify]
+  prepend_before_action :authenticate_and_authorize!, except: %i[webhook_incoming webhook_verify]
   skip_before_action :verify_csrf_token, only: %i[webhook_incoming webhook_verify]
 
   before_action :validate_webhook_signature!, only: :webhook_incoming

Некоторые файлы не были показаны из-за большого количества измененных файлов