Skip to content

Commit 0b41ae9

Browse files
authored
Fix ext_perm_user sign-up for non multi-tenant (onyx-dot-app#4743)
* OAuth w/ external user fix * Apply to basic auth as well
1 parent 9a12906 commit 0b41ae9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

backend/onyx/auth/users.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,12 @@ async def create(
323323
user = await self.get_by_email(user_create.email)
324324

325325
# we must use the existing user in the session if it matches
326-
# the user we just got by email
327-
user_by_session = await db_session.get(User, user.id)
328-
if user_by_session:
329-
user = user_by_session
326+
# the user we just got by email. Note that this only applies
327+
# to multi-tenant, due to the overwriting of the user_db
328+
if MULTI_TENANT:
329+
user_by_session = await db_session.get(User, user.id)
330+
if user_by_session:
331+
user = user_by_session
330332

331333
# Handle case where user has used product outside of web and is now creating an account through web
332334
if (
@@ -493,11 +495,13 @@ async def oauth_callback(
493495
# Handle case where user has used product outside of web and is now creating an account through web
494496
if not user.role.is_web_login():
495497
# We must use the existing user in the session if it matches
496-
# the user we just got by email/oauth
497-
if user.id:
498-
user_by_session = await db_session.get(User, user.id)
499-
if user_by_session:
500-
user = user_by_session
498+
# the user we just got by email/oauth. Note that this only applies
499+
# to multi-tenant, due to the overwriting of the user_db
500+
if MULTI_TENANT:
501+
if user.id:
502+
user_by_session = await db_session.get(User, user.id)
503+
if user_by_session:
504+
user = user_by_session
501505

502506
await self.user_db.update(
503507
user,

0 commit comments

Comments
 (0)