trestle-auth
trestle-auth copied to clipboard
Configure trestle to only accept admin users?
Hi - I am confused by how trestle-auth works, I have a User model in Devise which has an admin
boolean on it. I would like to limit access to all of Trestle to only users with admin == true
- it seems like that might be what trestle-auth
is for, but I can't figure out how to get it set up.
Does it have something to do with this
# Specify the parameter (along with a password) to be used to
# authenticate an administrator. Defaults to :email if not specified below.
#
config.auth.authenticate_with = -> { Devise.authentication_keys.first }
Yes, i'm confused with this too, and now after setup trestle-auth the devise user did not login anymore!
Same here. How would I limit access to Trestle to admins only? I also use Devise.
In my case it was simply setting a before_action in config/initializers/trestle.rb
config.before_action do |_controller|
unless current_user.admin?
redirect_to '/'
end
end