Sha256: fbfef7ca3528aac4b0aa60c4f391ebc5add3a1d42005272684f17cbc48520617

Contents?: true

Size: 784 Bytes

Versions: 12

Compression:

Stored size: 784 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

12 entries across 12 versions & 1 rubygems

Version Path
mno-enterprise-core-3.4.0 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.3.3 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.3.2 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.2.1 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.3.1 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.3.0 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.2.0 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.1.4 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.1.3 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.1.2 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.1.1 app/helpers/mno_enterprise/impersonate_helper.rb
mno-enterprise-core-3.1.0 app/helpers/mno_enterprise/impersonate_helper.rb