Sha256: 74ae2f4290ab133bf72a23a73136ee01ffa3103ca1b78eaacfe9cc9baf0f56cd

Contents?: true

Size: 964 Bytes

Versions: 29

Compression:

Stored size: 964 Bytes

Contents

module Workarea
  module Admin
    class InvalidImpersonation < StandardError; end

    class ImpersonationsController < Admin::ApplicationController
      include Storefront::CurrentCheckout
      required_permissions :people

      def create
        new_user = User.find(params[:user_id])
        raise InvalidImpersonation if new_user.admin?

        impersonate_user(new_user)
        login = Login.new(new_user, Order.new)
        self.current_order = login.previous_order || Order.new

        flash[:success] = t(
          'workarea.admin.users.flash_messages.started',
          email: new_user.email
        )
        redirect_to storefront.users_account_path
      end

      def destroy
        previous_user_id = cookies.signed[:user_id]
        stop_impersonation
        self.current_order = nil

        flash[:success] = t('workarea.admin.users.flash_messages.stopped')
        redirect_to user_path(previous_user_id)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
workarea-admin-3.4.40 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.39 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.38 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.37 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.36 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.35 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.34 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.33 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.32 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.31 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.30 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.29 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.28 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.27 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.26 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.25 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.24 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.23 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.22 app/controllers/workarea/admin/impersonations_controller.rb
workarea-admin-3.4.21 app/controllers/workarea/admin/impersonations_controller.rb