devise

https://github.com/plataformatec/devise

Ruby

Flexible authentication solution for Rails with Warden.

Devise::Controllers::Helpers::ClassMethods#devise_group

Define authentication filters and accessor helpers for a group of mappings.
These methods are useful when you are working with multiple mappings that
share some functionality. They are pretty much the same as the ones
defined for normal mappings.

Example:

  inside BlogsController (or any other controller, it doesn't matter which):
    devise_group :blogger, contains: [:user, :admin]

  Generated methods:
    authenticate_blogger!  # Redirects unless user or admin are signed in
    blogger_signed_in?     # Checks whether there is either a user or an admin signed in
    current_blogger        # Currently signed in user or admin
    current_bloggers       # Currently signed in user and admin

  Use:
    before_action :authenticate_blogger!              # Redirects unless either a user or an admin are authenticated
    before_action ->{ authenticate_blogger! :admin }  # Redirects to the admin login page
    current_blogger :user                             # Preferably returns a User if one is signed in

Source | Google | Stack overflow

Edit

git clone [email protected]:plataformatec/devise.git

cd devise

open lib/devise/controllers/helpers.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Devise--Controllers--Helpers--ClassMethods-devise_group-for-pr


# Commit to git

git add lib/devise/controllers/helpers.rbgit commit -m "better docs for Devise::Controllers::Helpers::ClassMethods#devise_group"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Devise--Controllers--Helpers--ClassMethods-devise_group-for-pr

hub pull-request


# Celebrate!