fix(current_user): revert false return in set_user_by_token when token is not present #1306
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some breaking behavior was introduced in https://github.com/lynndylanhurley/devise_token_auth/pull/1085/files#diff-787ec1bd1e5a87dca1d85fa6f8b2f7b3R65 in
set_user_by_token
. Previously, we would return an implicitnil
if the token was not present (unless @token ...
), but now we are returningfalse
in this case. This appears to be based on the refactoring of a subsequent (but completely inaccessible and confusing) call toreturn false unless @token
.The issue became immediately apparent after taking the referenced commit and encountering application logic to check various
current_user
state with elvis operators (eg -current_user&.can_view_something?
) which all blew up with the following:This PR reverts to the previous behavior.