mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Add Sentry user context to authentication concern
This commit is contained in:
parent
e8390a68d8
commit
763e222cdd
1 changed files with 15 additions and 0 deletions
|
@ -4,11 +4,13 @@ module Authentication
|
||||||
included do
|
included do
|
||||||
before_action :set_request_details
|
before_action :set_request_details
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
before_action :set_sentry_user
|
||||||
end
|
end
|
||||||
|
|
||||||
class_methods do
|
class_methods do
|
||||||
def skip_authentication(**options)
|
def skip_authentication(**options)
|
||||||
skip_before_action :authenticate_user!, **options
|
skip_before_action :authenticate_user!, **options
|
||||||
|
skip_before_action :set_sentry_user, **options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,4 +45,17 @@ module Authentication
|
||||||
Current.user_agent = request.user_agent
|
Current.user_agent = request.user_agent
|
||||||
Current.ip_address = request.ip
|
Current.ip_address = request.ip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_sentry_user
|
||||||
|
return unless defined?(Sentry) && ENV["SENTRY_DSN"].present?
|
||||||
|
|
||||||
|
if Current.user
|
||||||
|
Sentry.set_user(
|
||||||
|
id: Current.user.id,
|
||||||
|
email: Current.user.email,
|
||||||
|
username: Current.user.display_name,
|
||||||
|
ip_address: Current.ip_address
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue