Add a bit more logging

This commit is contained in:
shamoon 2025-02-22 07:26:48 -08:00
parent 742be59ffe
commit af2d812a2e

View File

@ -1,3 +1,4 @@
import logging
from urllib.parse import quote
from allauth.account.adapter import DefaultAccountAdapter
@ -9,6 +10,8 @@ from django.contrib.auth.models import User
from django.forms import ValidationError
from django.urls import reverse
logger = logging.getLogger("paperless.auth")
class CustomAccountAdapter(DefaultAccountAdapter):
def is_open_for_signup(self, request):
@ -72,6 +75,7 @@ class CustomAccountAdapter(DefaultAccountAdapter):
group_names: list[str] = settings.ACCOUNT_DEFAULT_GROUPS
if len(group_names) > 0:
groups = Group.objects.filter(name__in=group_names)
logger.debug(f"Adding default groups to user `{user}`: {group_names}")
user.groups.add(*groups)
user.save()
return user
@ -105,6 +109,9 @@ class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
group_names: list[str] = settings.SOCIAL_ACCOUNT_DEFAULT_GROUPS
if len(group_names) > 0:
groups = Group.objects.filter(name__in=group_names)
logger.debug(
f"Adding default social groups to user `{user}`: {group_names}",
)
user.groups.add(*groups)
user.save()
return user