Use user_id as token set indicator for settings (#6595)

Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
Rohit Malhotra 2025-02-03 20:36:47 -05:00 committed by GitHub
parent f24fbec165
commit 7151f75340
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View File

@ -13,9 +13,8 @@ app = APIRouter(prefix='/api')
@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(
@ -23,10 +22,10 @@ async def load_settings(request: Request) -> GETSettingsModel | None:
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

View File

@ -9,10 +9,10 @@ from openhands.server.types import AppMode, GhAuthenticationError, GHUnknownExce
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):
"""