devise
https://github.com/plataformatec/devise
Ruby
Flexible authentication solution for Rails with Warden.
ActionDispatch::Routing::Mapper#authenticated
Allow you to route based on whether a scope is authenticated. You
can optionally specify which scope and a block. The block accepts
a model and allows extra constraints to be done on the instance.
authenticated :admin do
root to: 'admin/dashboard#show', as: :admin_root
end
authenticated do
root to: 'dashboard#show', as: :authenticated_root
end
authenticated :user, lambda {|u| u.role == "admin"} do
root to: "admin/dashboard#show", as: :user_root
end
root to: 'landing#show'Edit
git clone [email protected]:plataformatec/devise.git
cd devise
open lib/devise/rails/routes.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-ActionDispatch--Routing--Mapper-authenticated-for-pr
# Commit to gitgit add lib/devise/rails/routes.rbgit commit -m "better docs for ActionDispatch::Routing::Mapper#authenticated"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-ActionDispatch--Routing--Mapper-authenticated-for-pr
hub pull-request
# Celebrate!