mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-12 12:40:29 +08:00
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:
parent
37caa2e0fe
commit
34f6b22efb
5
.changeset/tender-swans-trade.md
Normal file
5
.changeset/tender-swans-trade.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Strip leading and trailing spaces from username in login route
|
@ -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 (
|
||||
|
@ -1,2 +1,2 @@
|
||||
# Reference: https://github.com/sweepai/sweep/blob/main/sweep.yaml
|
||||
branch: dev
|
||||
branch: main
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user