Skip to content

Commit

Permalink
logout inactive users during current user query
Browse files Browse the repository at this point in the history
  • Loading branch information
matti-lamppu committed Nov 18, 2024
1 parent 3c10cfb commit 7b55523
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tilavarauspalvelu/api/graphql/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import graphene
from django.conf import settings
from django.contrib.auth import logout
from django.db import models
from graphene import Field
from graphene_django.debug import DjangoDebug
Expand Down Expand Up @@ -234,6 +235,10 @@ class Query(graphene.ObjectType):
debug = Field(DjangoDebug, name="_debug")

def resolve_current_user(root: None, info: GQLInfo, **kwargs: Any) -> User | None:
if not info.context.user.is_active:
logout(info.context)
return None

if info.context.user.is_anonymous:
return None

Expand Down

0 comments on commit 7b55523

Please sign in to comment.