Update auth.py
Browse files
auth.py
CHANGED
@@ -46,11 +46,13 @@ def authenticate_user(db: Session, email: str, password: str):
|
|
46 |
# Check if the user with the provided email exists in the database
|
47 |
user = get_user_by_email(db, email)
|
48 |
if user is None:
|
49 |
-
|
|
|
50 |
|
51 |
# Check if the provided password is correct (You should verify the password)
|
52 |
if not pwd_context.verify(password, user.hashed_password):
|
53 |
-
|
|
|
54 |
|
55 |
return user # Authentication succeeded
|
56 |
|
|
|
46 |
# Check if the user with the provided email exists in the database
|
47 |
user = get_user_by_email(db, email)
|
48 |
if user is None:
|
49 |
+
raise HTTPException(status_code=400, detail="User not found")
|
50 |
+
# return None # User not found
|
51 |
|
52 |
# Check if the provided password is correct (You should verify the password)
|
53 |
if not pwd_context.verify(password, user.hashed_password):
|
54 |
+
raise HTTPException(status_code=400, detail="Incorrect password")
|
55 |
+
# return None # Incorrect password
|
56 |
|
57 |
return user # Authentication succeeded
|
58 |
|