Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/revise_auth/routes.rb
Instance Method Summary collapse
- #authenticated(block = nil) ⇒ Object
-
#revise_auth ⇒ Object
Adds helpers for config/routes.rb to constraint routes with authentication.
- #unauthenticated ⇒ Object
Instance Method Details
#authenticated(block = nil) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/revise_auth/routes.rb', line 26 def authenticated(block = nil) constraints ->(request) { rc = ReviseAuth::RouteConstraint.new(request) rc.user_signed_in? && (block.nil? || block.call(rc.current_user)) } do yield end end |
#revise_auth ⇒ Object
Adds helpers for config/routes.rb to constraint routes with authentication
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/revise_auth/routes.rb', line 5 def revise_auth scope module: :revise_auth do revise_registration get "login", to: "sessions#new" post "login", to: "sessions#create" revise_profile patch "profile/email", to: "email#update" patch "profile/password", to: "password#update" resources :password_resets, param: :token, only: [:new, :create, :edit, :update] # Email confirmation get "profile/email", to: "email#show" delete "logout", to: "sessions#destroy" end end |
#unauthenticated ⇒ Object
35 36 37 38 39 |
# File 'lib/revise_auth/routes.rb', line 35 def unauthenticated constraints ->(request) { !ReviseAuth::RouteConstraint.new(request).user_signed_in? } do yield end end |