mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-11-25 23:59:09 -06:00
Enhancement: support default groups for regular and social account signup (#9039)
This commit is contained in:
@@ -30,3 +30,21 @@ def handle_failed_login(sender, credentials, request, **kwargs):
|
||||
log_output += f" from private IP `{client_ip}`."
|
||||
|
||||
logger.info(log_output)
|
||||
|
||||
|
||||
def handle_social_account_updated(sender, request, sociallogin, **kwargs):
|
||||
"""
|
||||
Handle the social account update signal.
|
||||
"""
|
||||
from django.contrib.auth.models import Group
|
||||
|
||||
social_account_groups = sociallogin.account.extra_data.get(
|
||||
"groups",
|
||||
[],
|
||||
) # None if not found
|
||||
if settings.SOCIAL_ACCOUNT_SYNC_GROUPS and social_account_groups is not None:
|
||||
groups = Group.objects.filter(name__in=social_account_groups)
|
||||
logger.debug(
|
||||
f"Syncing groups for user `{sociallogin.user}`: {social_account_groups}",
|
||||
)
|
||||
sociallogin.user.groups.set(groups, clear=True)
|
||||
|
||||
Reference in New Issue
Block a user