You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Devise has a handy feature called devise_group (documentation), which creates a group with your multiple devise models.
The docs are really self explanatory. If you have 2 devise models named, for instance, Admin and User, you can use devise_group like so:
class ApplicationController < ActionController::Base
devise_group :blogger, contains: [:user, :admin]
end
This gives us, alongside with authenticate_user! and authenticate_admin!, the method authenticate_blogger!, which would redirect unless user or admin were signed in.
If I understood correctly from the docs, the gem's official way of supporting multiple models would require to declare multiple lines like this:
acts_as_token_authentication_handler_for Admin, fallback: :none
acts_as_token_authentication_handler_for User
Since this repetition is not, imho, very DRY (specially with the only and except filters), and also prone to errors, my request is that the gem (due to having close Devise integration) supports an API like this:
Devise has a handy feature called devise_group (documentation), which creates a group with your multiple devise models.
The docs are really self explanatory. If you have 2 devise models named, for instance, Admin and User, you can use devise_group like so:
This gives us, alongside with
authenticate_user!
andauthenticate_admin!
, the methodauthenticate_blogger!
, which would redirect unless user or admin were signed in.If I understood correctly from the docs, the gem's official way of supporting multiple models would require to declare multiple lines like this:
Since this repetition is not, imho, very DRY (specially with the
only
andexcept
filters), and also prone to errors, my request is that the gem (due to having close Devise integration) supports an API like this:acts_as_token_authentication_handler_for_group :blogger
or even
acts_as_token_authentication_handler_for :group, name: :blogger
What do you guys think?
The text was updated successfully, but these errors were encountered: