Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/foyer/rails.rb
Instance Method Summary collapse
Instance Method Details
#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 |