Skip to content

Commit

Permalink
Merge pull request #3499 from Semihal/fix-oauth-openid
Browse files Browse the repository at this point in the history
fix: First OIDC account is not admin
  • Loading branch information
tjbck authored Jun 29, 2024
2 parents 58398b6 7d10dac commit d3a67b4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1944,14 1944,19 @@ async def oauth_callback(provider: str, request: Request, response: Response):
picture_url = ""
if not picture_url:
picture_url = "/user.png"
role = (
"admin"
if Users.get_num_users() == 0
else webui_app.state.config.DEFAULT_USER_ROLE
)
user = Auths.insert_new_auth(
email=email,
password=get_password_hash(
str(uuid.uuid4())
), # Random password, not used
name=user_data.get("name", "User"),
profile_image_url=picture_url,
role=webui_app.state.config.DEFAULT_USER_ROLE,
role=role,
oauth_sub=provider_sub,
)

Expand All @@ -1978,7 1983,7 @@ async def oauth_callback(provider: str, request: Request, response: Response):
# Set the cookie token
response.set_cookie(
key="token",
value=token,
value=jwt_token,
httponly=True, # Ensures the cookie is not accessible via JavaScript
)

Expand Down

0 comments on commit d3a67b4

Please sign in to comment.