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

Impossible to get list of baskets as admin on api/baskets endpoint #359

Open
gmaOCR opened this issue Oct 17, 2024 · 1 comment
Open

Impossible to get list of baskets as admin on api/baskets endpoint #359

gmaOCR opened this issue Oct 17, 2024 · 1 comment

Comments

@gmaOCR
Copy link

gmaOCR commented Oct 17, 2024

I've tried 2 cases of auth with Postman: basic and bear with JWT.

Basic auth response 500 : NoneType' object has no attribute 'strategy'
Bearer auth response 200 but list empty with baskets in the DB

@gmaOCR gmaOCR changed the title Impossible to get list of baskets as admin on api/baskets endpoints Impossible to get list of baskets as admin on api/baskets endpoint Oct 17, 2024
@gmaOCR
Copy link
Author

gmaOCR commented Oct 17, 2024

After some modifications, now the code is 403 for Basic auth and Bearer
I've started investigations in oscarapi>permissions.py

    def has_object_permission(self, request, view, obj):
        import pdb
        pdb.set_trace()
        return request_allows_access_to(request, obj)
(Pdb) print(request)
<rest_framework.request.Request: GET '/api/baskets/404/'>
(Pdb) print(view)
<oscarapi.views.basic.BasketDetail object at 0x7faf58ca0590>
(Pdb) print(request.user)
admin
(Pdb) print(obj)
Open cart (owner: None, lines: 1)
(Pdb) print(request.user.is_staff)
True

Go in oscarapi>basket>operations.py

    if basket.can_be_edited:
        if request.user.is_authenticated:
            return request.user == basket.owner

        return get_basket_id_from_session(request) == basket.pk

    return False

Can I suggest to evaluate the admin case here in this last function ? Hope it helps

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

No branches or pull requests

1 participant