mirror of
https://github.com/open-webui/open-webui
synced 2025-01-18 00:30:51 +00:00
Merge pull request #3499 from Semihal/fix-oauth-openid
fix: First OIDC account is not admin
This commit is contained in:
commit
d3a67b44cd
@ -1944,6 +1944,11 @@ async def oauth_callback(provider: str, request: Request, response: Response):
|
|||||||
picture_url = ""
|
picture_url = ""
|
||||||
if not picture_url:
|
if not picture_url:
|
||||||
picture_url = "/user.png"
|
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(
|
user = Auths.insert_new_auth(
|
||||||
email=email,
|
email=email,
|
||||||
password=get_password_hash(
|
password=get_password_hash(
|
||||||
@ -1951,7 +1956,7 @@ async def oauth_callback(provider: str, request: Request, response: Response):
|
|||||||
), # Random password, not used
|
), # Random password, not used
|
||||||
name=user_data.get("name", "User"),
|
name=user_data.get("name", "User"),
|
||||||
profile_image_url=picture_url,
|
profile_image_url=picture_url,
|
||||||
role=webui_app.state.config.DEFAULT_USER_ROLE,
|
role=role,
|
||||||
oauth_sub=provider_sub,
|
oauth_sub=provider_sub,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1978,7 +1983,7 @@ async def oauth_callback(provider: str, request: Request, response: Response):
|
|||||||
# Set the cookie token
|
# Set the cookie token
|
||||||
response.set_cookie(
|
response.set_cookie(
|
||||||
key="token",
|
key="token",
|
||||||
value=token,
|
value=jwt_token,
|
||||||
httponly=True, # Ensures the cookie is not accessible via JavaScript
|
httponly=True, # Ensures the cookie is not accessible via JavaScript
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user