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

fix: First OIDC account is not admin #3499

Merged
merged 6 commits into from
Jun 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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