Skip to content
Discussion options

You must be logged in to vote

Override perform_authentication() on a base view. APIView.initial() runs it before check_permissions() (views.py), so call super() first and load the membership right after:

class WorkspaceContextMixin:
    def perform_authentication(self, request):
        super().perform_authentication(request)
        request.member = None
        if request.user.is_authenticated:
            request.member = resolve_workspace_member(
                request.user, request.headers.get("Workspace-ID"))

Put the mixin before the DRF base class and it works for viewsets too.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lrodri04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants