- Remove duplicated app_allows_user_cached?/headers_for_user_cached methods; call model methods directly - Fix sliding-window rate limit bug by using increment instead of write (avoids TTL reset) - Use cached app lookup in validate_redirect_url instead of hitting DB on every unauthorized request - Add cache busting to ApplicationGroup so group assignment changes invalidate the cache - Eager-load user groups (includes(user: :groups)) to eliminate N+1 queries - Replace pluck(:name) with map(&:name) to use already-loaded associations - Remove hardcoded fallback domain, dead methods, and unnecessary comments - Fix test indentation and make group-order assertions deterministic Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
15 lines
310 B
Ruby
15 lines
310 B
Ruby
class ApplicationGroup < ApplicationRecord
|
|
belongs_to :application
|
|
belongs_to :group
|
|
|
|
validates :application_id, uniqueness: {scope: :group_id}
|
|
|
|
after_commit :bust_forward_auth_cache
|
|
|
|
private
|
|
|
|
def bust_forward_auth_cache
|
|
Rails.application.config.forward_auth_cache&.delete("fa_apps")
|
|
end
|
|
end
|