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

fix(current_user): revert false return in set_user_by_token when token is not present #1306

Merged
merged 1 commit into from
Jun 17, 2019
Merged

fix(current_user): revert false return in set_user_by_token when token is not present #1306

merged 1 commit into from
Jun 17, 2019

Conversation

booleanbetrayal
Copy link
Collaborator

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 implicit nil if the token was not present (unless @token ...), but now we are returning false in this case. This appears to be based on the refactoring of a subsequent (but completely inaccessible and confusing) call to return 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:

NoMethodError: undefined method `can_view_something?' for false:FalseClass

This PR reverts to the previous behavior.

@booleanbetrayal booleanbetrayal merged commit 237f49d into lynndylanhurley:master Jun 17, 2019
@booleanbetrayal booleanbetrayal deleted the revert_false_return branch June 17, 2019 16:03
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

Successfully merging this pull request may close these issues.

1 participant