Closed unikitty37 closed 4 years ago
hey @unikitty37 can you paste the whole controller and which version of knock you are using?
Thanks — unfortunately, I gave up on Knock and switched to devise-jwt.
I've had a look in the git reflog, but can't find any actual commits with Knock in them, so I'll close this issue as there's probably not much you'll be able to do to help without that info. Sorry for the waste of time.
When the user is logged out, or passes an invalid token,
current_user
returnsnil
.What I would like is for
current_user
to return an instance of myNullUser
class instead, so that I don't have to keep checking for nil everywhere.I've tried this in
controllers/application_controller.rb
but it fails with
NameError (undefined method 'current_user' for class 'ApplicationController')
. This method worked with Devise — I assume it's failing because of the way Knock definescurrent_user
.I'm using this for now
but it's less than ideal because other gems are expecting to use
current_user
and I'm not sure right now if they can all be easily configured to use something else. Is there a clean way of customisingcurrent_user
?