Sha256: 6b1244bf0934267677ee89fb00c9a35b5713f6e823870d3fdcc679b804ade2f6

Contents?: true

Size: 783 Bytes

Versions: 18

Compression:

Stored size: 783 Bytes

Contents

module MnoEnterprise
  module ImpersonateHelper

    # current_user changes from a staff user to
    # +new_user+; current user stored in +session[:impersonator_user_id]+
    def impersonate(new_user)
      session[:impersonator_user_id] = current_user.id
      sign_out(current_user)
      sign_in new_user
    end

    # revert the +current_user+ back to the staff user
    # stored in +session[:impersonator_user_id]+
    def revert_impersonate
      return unless current_impersonator
      sign_out(current_user)
      sign_in(current_impersonator)
      session[:impersonator_user_id] = nil
    end

    def current_impersonator
      return unless session[:impersonator_user_id]
      @admin_user ||= MnoEnterprise::User.find(session[:impersonator_user_id])
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mno-enterprise-core-3.0.7 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.9 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.0.6 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.8 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.0.5 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.7 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.6 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.5 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.0.4 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.4 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.0.3 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.3 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.0.2 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.2 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.0.1 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.1 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.0.0 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-2.0.0 app/helpers/mno_enterprise/impersonate_helper.rb