Skip to content

Commit

Permalink
Use user_id as token set indicator for settings (All-Hands-AI#6595)
Browse files Browse the repository at this point in the history
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
  • Loading branch information
2 people authored and Kevin Chen committed Feb 4, 2025
1 parent 2952e7a commit 257ed95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions openhands/server/routes/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
@app.get('/settings')
async def load_settings(request: Request) -> GETSettingsModel | None:
try:
settings_store = await SettingsStoreImpl.get_instance(
config, get_user_id(request)
)
user_id = get_user_id(request)
settings_store = await SettingsStoreImpl.get_instance(config, user_id)
settings = await settings_store.load()
if not settings:
return JSONResponse(
status_code=status.HTTP_404_NOT_FOUND,
content={'error': 'Settings not found'},
)

github_token = request.state.github_token
token_is_set = bool(user_id) or bool(request.state.github_token)
settings_with_token_data = GETSettingsModel(
**settings.model_dump(),
github_token_is_set=bool(github_token),
github_token_is_set=token_is_set,
)
settings_with_token_data.llm_api_key = settings.llm_api_key

Expand Down
2 changes: 1 addition & 1 deletion openhands/server/services/github_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

class GitHubService:
BASE_URL = 'https://api.github.com'
token: str = ''

def __init__(self, user_id: str | None):
self.user_id = user_id
self.token = ''

async def _get_github_headers(self):
"""
Expand Down

0 comments on commit 257ed95

Please sign in to comment.