When using devise, one usually uses a before_action
to authenticate a user:
This always requires a login though. What if you want to login a user if possible, but ignore it if the user is not logged in? You need to use warden (the underlying authentication framework devise uses) directly: