fix: enable lograge in superadmin path (#7026)
* fix: lograge superadmin path * chore: add spec for superadmin devise session controller * chore: address review comment
This commit is contained in:
@@ -770,6 +770,7 @@ GEM
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin-20
|
||||
arm64-darwin-21
|
||||
x86_64-darwin-18
|
||||
x86_64-darwin-20
|
||||
x86_64-darwin-21
|
||||
|
||||
@@ -4,12 +4,13 @@ if ActiveModel::Type::Boolean.new.cast(ENV.fetch('LOGRAGE_ENABLED', false)).pres
|
||||
Rails.application.configure do
|
||||
config.lograge.enabled = true
|
||||
config.lograge.formatter = Lograge::Formatters::Json.new
|
||||
|
||||
config.lograge.custom_payload do |controller|
|
||||
# Fixes https://github.com/chatwoot/chatwoot/issues/6922
|
||||
user_id = controller.try(:current_user).try(:id) unless controller.is_a?(SuperAdmin::Devise::SessionsController)
|
||||
{
|
||||
host: controller.request.host,
|
||||
remote_ip: controller.request.remote_ip,
|
||||
user_id: controller.current_user.try(:id)
|
||||
user_id: user_id
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Super Admin', type: :request do
|
||||
describe '/super_admin' do
|
||||
it 'renders the login page' do
|
||||
with_modified_env LOGRAGE_ENABLED: 'true' do
|
||||
get '/super_admin/sign_in'
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user