Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

"Invalid payload" error if user_id is 0 #28

Closed
jorisvddonk opened this issue Aug 12, 2014 · 2 comments
Closed

"Invalid payload" error if user_id is 0 #28

jorisvddonk opened this issue Aug 12, 2014 · 2 comments

Comments

@jorisvddonk
Copy link

When trying to make a call to a restricted resource as the user with user_id 0, you get an "Invalid payload" error.

This seems to be caused by the following code in authentication.py:

        if user_id:
            user = User.objects.get(pk=user_id, is_active=True)
        else:
            msg = 'Invalid payload'
            raise exceptions.AuthenticationFailed(msg)

(if user_id evaluates to False if user_id == 0)
Not sure if this is by design or not.

@jpadilla
Copy link
Owner

@jorisvddonk definitely an edge case, was not expecting a scenario where user_id would be 0. You can submit a pull request with changes that'd fix this for you and a test case along with those changes. Maybe we should be doing if user_id is not None instead.

@jpadilla
Copy link
Owner

@jorisvddonk closing this until further updates

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants