Add Docker support with Dockerfile and entrypoint
Some checks failed
Docker / build (push) Failing after 1m11s
Some checks failed
Docker / build (push) Failing after 1m11s
This commit is contained in:
parent
faf880a236
commit
f38b947390
8 changed files with 118 additions and 2 deletions
29
allauth_oauth/signals.py
Normal file
29
allauth_oauth/signals.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# This file is part of photo21
|
||||
# Copyright (C) 2022 Amicale des élèves de l'ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from allauth.socialaccount.signals import pre_social_login
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
||||
@receiver(pre_social_login)
|
||||
def sync_user_fields(sender, request, sociallogin, **kwargs):
|
||||
if not sociallogin.is_existing:
|
||||
return
|
||||
|
||||
user = sociallogin.user
|
||||
data = sociallogin.account.extra_data
|
||||
changed = False
|
||||
|
||||
email = data.get("email")
|
||||
if email and user.email != email:
|
||||
user.email = email
|
||||
changed = True
|
||||
|
||||
username = data.get("username")
|
||||
if username and user.username != username:
|
||||
user.username = username
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
user.save()
|
||||
Loading…
Add table
Add a link
Reference in a new issue