-
With Devise, you can write something like this :
With Rodauth-Rails, you can write something like this :
Is there a way to access the current_account in the constraints ? Not only the "rodauth" object ? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can do it this way: constraints(
Rodauth::Rails.authenticated do |rodauth|
User.find(rodauth.session_value)&.admin?
end,
) do
# ...
end |
Beta Was this translation helpful? Give feedback.
-
Thanks @renchap for posting a solution. As of version 1.2, you can now retrieve the model instance via the constraints Rodauth::Rails.authenticated { |rodauth| rodauth.rails_account.admin? } do
# ...
end This has the benefit of not re-fetching the account record when |
Beta Was this translation helpful? Give feedback.
You can do it this way: