Commit 0a81ca7
Changed files (2)
app
controllers
scim
models
app/controllers/scim/controller.rb
@@ -15,13 +15,11 @@ module Scim
end
def current_user
- @current_user ||= authenticate_with_http_token do |token|
- Token.authenticate(token)
- end
+ Current.user
end
def current_user?
- current_user.present?
+ Current.user?
end
protected
@@ -37,7 +35,10 @@ module Scim
private
def authenticate!
- render plain: "Unauthorized", status: :unauthorized unless current_user?
+ Current.user = authenticate_with_http_token do |token|
+ Token.authenticate(token)
+ end
+ render plain: "Unauthorized", status: :unauthorized unless Current.user?
end
def apply_scim_content_type
app/models/current.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class Current < ActiveSupport::CurrentAttributes
+ attribute :client, :user
+ attribute :request_id, :user_agent, :ip_address
+
+ def user?
+ user.present?
+ end
+end