Closed ghost closed 4 years ago
You could have them set a proc on your config object that you can call to get the current user.
@ffmike thank you, but this is not needed, you can see in the config this option, which you can use to check permissions
config.verify_access_proc = proc { |controller| controller.current_user && controller.current_user.admin? }
I want to keep gem as much as possible independent from main app
👍A reasonable approach. Note that the code in the config does not work in the case of apps using Clearance to provide current_user, but I'll work around.
you have access to the controller, so potentially you can do whatever you want.
I took that code from another my gem: https://github.com/igorkasyanchuk/any_login which by the way you can try! I can bet with you that it will be useful for you and it works with clearance.
@ffmike just noticed that you are the owner of http://afreshcup.com site! I'm really reading it for maybe 4-5 years like almost every day as a good source of news 👍 👍 💯
Thanks! And hope I didn't sound unfriendly above; I'm enjoying trying out this gem.
of course no, I really like that I see the first PR's for the gem :)
If you have some desire I actually have a good list of ideas - https://github.com/igorkasyanchuk/rails_performance#todo so whenever you have time you can pick any item from the list :)
Make BaseController a subclass of ApplicationController rather than directly from ActionController::Base, so that app-specific code can be used in verifying access.
Maybe I'm missing something, but I couldn't see any other good way to get at current_user in the context of the rails performance controller. Clearance puts that on the application's own main controller, not on ActionController::Base.