Strip leading and trailing spaces from username in login route (#5104)

* Update gradio/routes.py

* Update test/test_routes.py

* consolidate test

* add changeset

* update sweep yaml

---------

Co-authored-by: sweep-ai[bot] <128439645+sweep-ai[bot]@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
sweep-ai[bot] 2023-08-04 17:37:34 -04:00 committed by GitHub
parent 37caa2e0fe
commit 34f6b22efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": minor
---
feat:Strip leading and trailing spaces from username in login route

View File

@ -221,7 +221,7 @@ class App(FastAPI):
@app.post("/login")
@app.post("/login/")
def login(form_data: OAuth2PasswordRequestForm = Depends()):
username, password = form_data.username, form_data.password
username, password = form_data.username.strip(), form_data.password
if app.auth is None:
return RedirectResponse(url="/", status_code=status.HTTP_302_FOUND)
if (

View File

@ -1,2 +1,2 @@
# Reference: https://github.com/sweepai/sweep/blob/main/sweep.yaml
branch: dev
branch: main

View File

@ -465,6 +465,12 @@ class TestAuthenticatedRoutes:
)
assert response.status_code == 400
response = client.post(
"/login",
data={"username": " test ", "password": "correct_password"},
)
assert response.status_code == 200
class TestQueueRoutes:
@pytest.mark.asyncio