Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev #3621

Merged
merged 14 commits into from
Jul 4, 2024
Prev Previous commit
Next Next commit
fix username claim
  • Loading branch information
Sergey Mihaylin committed Jun 28, 2024
commit 9f32e9ef602fdb25e69a95d41ae4a96358ed88f2
6 changes: 3 additions & 3 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,8 1920,7 @@ async def oauth_callback(provider: str, request: Request, response: Response):
# If the user does not exist, check if signups are enabled
if ENABLE_OAUTH_SIGNUP.value:
# Check if an existing user with the same email already exists
email_claim = webui_app.state.config.OAUTH_USERNAME_CLAIM
existing_user = Users.get_user_by_email(user_data.get(email_claim, "").lower())
existing_user = Users.get_user_by_email(user_data.get("email", "").lower())
if existing_user:
raise HTTPException(400, detail=ERROR_MESSAGES.EMAIL_TAKEN)

Expand All @@ -1946,12 1945,13 @@ async def oauth_callback(provider: str, request: Request, response: Response):
picture_url = ""
if not picture_url:
picture_url = "/user.png"
username_claim = webui_app.state.config.OAUTH_USERNAME_CLAIM
user = Auths.insert_new_auth(
email=email,
password=get_password_hash(
str(uuid.uuid4())
), # Random password, not used
name=user_data.get("name", "User"),
name=user_data.get(username_claim, "User"),
profile_image_url=picture_url,
role=webui_app.state.config.DEFAULT_USER_ROLE,
oauth_sub=provider_sub,
Expand Down