Gregniuki commited on
Commit
3f1d12a
1 Parent(s): bbe5c13

Update auth.py

Browse files
Files changed (1) hide show
  1. auth.py +4 -2
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
- return None # User not found
 
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
- return None # Incorrect password
 
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