module Locomotive::Steam::Middlewares::Concerns::AuthHelpers

Public Instance Methods

authenticated?() click to toggle source
# File lib/locomotive/steam/middlewares/concerns/auth_helpers.rb, line 6
def authenticated?
  !!env['steam.authenticated_entry']
end
authenticated_entry_type() click to toggle source
# File lib/locomotive/steam/middlewares/concerns/auth_helpers.rb, line 10
def authenticated_entry_type
  request.session[:authenticated_entry_type]
end
store_authenticated(entry) click to toggle source
# File lib/locomotive/steam/middlewares/concerns/auth_helpers.rb, line 14
def store_authenticated(entry)
  type = entry ? entry.content_type.slug : authenticated_entry_type

  request.session[:authenticated_entry_type]  = type.to_s
  request.session[:authenticated_entry_id]    = entry&._id.to_s

  env['steam.authenticated_entry'] = nil if entry.nil?

  log "[Auth] authenticated #{type.to_s.singularize} ##{entry&._id.to_s}"

  liquid_assigns["current_#{type.singularize}"] = entry
end