Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure trestle to only accept admin users? #37

Open
Bandes opened this issue Aug 18, 2021 · 3 comments
Open

Configure trestle to only accept admin users? #37

Bandes opened this issue Aug 18, 2021 · 3 comments

Comments

@Bandes
Copy link

Bandes commented Aug 18, 2021

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 }
@dcalixto
Copy link

Yes, i'm confused with this too, and now after setup trestle-auth the devise user did not login anymore!

@ohpreis
Copy link

ohpreis commented Nov 9, 2021

Same here. How would I limit access to Trestle to admins only? I also use Devise.

@zealot128
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants