Sha256: 5c2f080d3f1350f7b9f22c7a6c675a685ee5118971c4937d1e944908c358234e

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

module Locomotive
  class ContentEntryImpersonationsController < BaseController

    account_required & within_site

    def create
      if content_entry.with_authentication?
        # automatically sign in the entry
        session[:authenticated_entry_type]    = content_type.slug
        session[:authenticated_entry_id]      = content_entry.id.to_s

        # add a flag to notify that the sign in was done by impersonating the entry
        session[:authenticated_impersonation] = '1'

        redirect_to preview_url(current_site)
      else
        redirect_to content_entries_path(current_site, content_type.slug)
      end
    end

    private

    def content_type
      @content_type ||= current_site.content_types.where(slug: params[:slug]).first!
    end

    def content_entry
      @content_entry ||= content_type.entries.find(params[:content_entry_id])
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locomotivecms-4.0.0.rc0 app/controllers/locomotive/content_entry_impersonations_controller.rb