mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
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:
parent
f24fbec165
commit
7151f75340
@ -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
|
||||
|
||||
|
||||
@ -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):
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user