Sha256: 1225a986766aed3d157ac5859ab744126a0243ca776928cebe749ff47a1f09d2
Contents?: true
Size: 886 Bytes
Versions: 8
Compression:
Stored size: 886 Bytes
Contents
require 'devise/strategies/authenticatable' require 'devise/strategies/base' module Devise module Strategies class ImpersonateStrategy < Authenticatable include ::G5Authenticatable::ImpersonateSessionable # Prevents unauthorized users to impersonate another user when visiting the correct URL def valid? allowed = user_to_impersonate.present? && able_to_impersonate?(impersonation_user, user_to_impersonate) return allowed if allowed clear_impersonation_keys true rescue # Safety net clear_impersonation_keys false end def authenticate! if user_to_impersonate.present? success!(user_to_impersonate) else clear_impersonation_keys fail('You do not have sufficient access to this account') end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems