Module DeviseTokenAuth::Controllers::Helpers::ClassMethods
In: lib/devise_token_auth/controllers/helpers.rb

Methods

Public Instance methods

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
    render_authenticate_error         # Render error unless user or admin are signed in

  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

[Validate]