Method: ActionDispatch::Routing::Mapper#authenticate
- Defined in:
- lib/foyer/rails.rb
#authenticate(guard = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/foyer/rails.rb', line 6 def authenticate(guard = nil) constraint = lambda do |request| user_id = request.env['rack.session'][Foyer.session_key].try(:with_indifferent_access).try(:[], :id) break unless user_id guard.nil? ? true : guard.call(Foyer.user_finder.call(user_id)) end constraints(constraint) do yield end end |