Sha256: 4392942118a0017b1f828f5195fdb0c9e03b077cb8f4e37c8ed9ef32e5e9255f
Contents?: true
Size: 923 Bytes
Versions: 18
Compression:
Stored size: 923 Bytes
Contents
# frozen_string_literal: true 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
18 entries across 18 versions & 1 rubygems