Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Arturo Montejo Ráez
/
WBT2425_0
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
20
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
03de49a5
authored
Mar 25, 2025
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
change status error code when login fails from 400 (bad request) to 401 (unauthorized)
parent
412c8455
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
1 deletions
fastapi/auth.py
fastapi/auth.py
View file @
03de49a5
...
...
@@ -78,7 +78,7 @@ def authenticate_user(db: Session, email: str, password: str):
def
login_user
(
db
,
email
:
str
,
password
:
str
):
user
=
authenticate_user
(
db
,
email
,
password
)
if
not
user
:
raise
HTTPException
(
status_code
=
40
0
,
detail
=
"Incorrect username or password"
)
raise
HTTPException
(
status_code
=
40
1
,
detail
=
"Incorrect username or password"
)
access_token_expires
=
timedelta
(
minutes
=
ACCESS_TOKEN_EXPIRE_MINUTES
)
access_token
=
create_access_token
(
data
=
{
"sub"
:
user
.
email
,
"role"
:
user
.
role
,
"id"
:
user
.
id
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment