Skip to content

Commit fe01743

Browse files
committed
update according to review
1 parent 3db4f3c commit fe01743

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

dojo/pipeline.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ def sanitize_username(username):
183183
def create_user(strategy, details, backend, user=None, *args, **kwargs):
184184
if not settings.SOCIAL_AUTH_CREATE_USER:
185185
return None
186-
username = details.get("username")
187-
if not username:
188-
username = details.get("email")
189-
if not username:
190-
username = details.get("fullname")
186+
username = details.get(settings.SOCIAL_AUTH_CREATE_USER_MAPPING)
191187
details["username"] = sanitize_username(username)
192188
return social_core.pipeline.user.create_user(strategy, details, backend, user, args, kwargs)

dojo/settings/settings.dist.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
DD_FORGOT_USERNAME=(bool, True), # do we show link "I forgot my username" on login screen
114114
DD_SOCIAL_AUTH_SHOW_LOGIN_FORM=(bool, True), # do we show user/pass input
115115
DD_SOCIAL_AUTH_CREATE_USER=(bool, True), # if True creates user at first login
116+
DD_SOCIAL_AUTH_CREATE_USER_MAPPING=(str, "username"), # could also be email or fullname
116117
DD_SOCIAL_LOGIN_AUTO_REDIRECT=(bool, False), # auto-redirect if there is only one social login method
117118
DD_SOCIAL_AUTH_TRAILING_SLASH=(bool, True),
118119
DD_SOCIAL_AUTH_OIDC_AUTH_ENABLED=(bool, False),
@@ -574,6 +575,7 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
574575
SHOW_LOGIN_FORM = env("DD_SOCIAL_AUTH_SHOW_LOGIN_FORM")
575576
SOCIAL_LOGIN_AUTO_REDIRECT = env("DD_SOCIAL_LOGIN_AUTO_REDIRECT")
576577
SOCIAL_AUTH_CREATE_USER = env("DD_SOCIAL_AUTH_CREATE_USER")
578+
SOCIAL_AUTH_CREATE_USER_MAPPING = env("DD_SOCIAL_AUTH_CREATE_USER_MAPPING")
577579

578580
SOCIAL_AUTH_STRATEGY = "social_django.strategy.DjangoStrategy"
579581
SOCIAL_AUTH_STORAGE = "social_django.models.DjangoStorage"

0 commit comments

Comments
 (0)