Skip to content

Commit

Permalink
Merge branch 'main' into test/discoverybench-openhands-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
suranah authored Oct 30, 2024
2 parents 7f3ab98 + e21abce commit adf0b87
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/feedback-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function FeedbackModal({
Password: {password} <span className="text-gray-500">(copy)</span>
</span>
</div>,
{ duration: 5000 },
{ duration: 10000 },
);
};

Expand Down
33 changes: 20 additions & 13 deletions openhands/server/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@
GITHUB_CLIENT_ID = os.getenv('GITHUB_CLIENT_ID', '').strip()
GITHUB_CLIENT_SECRET = os.getenv('GITHUB_CLIENT_SECRET', '').strip()

# New global variable to store the user list
GITHUB_USER_LIST = None


# New function to load the user list
def load_github_user_list():
global GITHUB_USER_LIST
waitlist = os.getenv('GITHUB_USER_LIST_FILE')
if waitlist:
with open(waitlist, 'r') as f:
GITHUB_USER_LIST = [line.strip() for line in f if line.strip()]


load_github_user_list()


@asynccontextmanager
async def lifespan(app: FastAPI):
Expand Down Expand Up @@ -836,22 +851,14 @@ class User(BaseModel):

@app.post('/api/authenticate')
def authenticate(user: User | None = None):
waitlist = os.getenv('GITHUB_USER_LIST_FILE')
global GITHUB_USER_LIST

# Only check if waitlist is provided
if waitlist is not None:
try:
with open(waitlist, 'r') as f:
users = f.read().splitlines()
if user is None or user.login not in users:
return JSONResponse(
status_code=status.HTTP_403_FORBIDDEN,
content={'error': 'User not on waitlist'},
)
except FileNotFoundError:
if GITHUB_USER_LIST:
if user is None or user.login not in GITHUB_USER_LIST:
return JSONResponse(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
content={'error': 'Waitlist file not found'},
status_code=status.HTTP_403_FORBIDDEN,
content={'error': 'User not on waitlist'},
)

return JSONResponse(
Expand Down

0 comments on commit adf0b87

Please sign in to comment.