GitHub Actions
commited on
Commit
·
196858e
1
Parent(s):
54e926d
Deploy backend from GitHub Actions
Browse files🚀 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
- routes/auth.py +11 -2
routes/auth.py
CHANGED
|
@@ -155,10 +155,19 @@ async def register(request: Request, register_data: RegisterRequest, db: Session
|
|
| 155 |
async def login(request: Request, login_data: LoginRequest, db: Session = Depends(get_db)):
|
| 156 |
"""Login with email and password"""
|
| 157 |
user = db.query(User).filter(User.email == login_data.email).first()
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
raise HTTPException(
|
| 160 |
status_code=status.HTTP_401_UNAUTHORIZED,
|
| 161 |
-
detail="Incorrect email or password",
|
| 162 |
headers={"WWW-Authenticate": "Bearer"},
|
| 163 |
)
|
| 164 |
|
|
|
|
| 155 |
async def login(request: Request, login_data: LoginRequest, db: Session = Depends(get_db)):
|
| 156 |
"""Login with email and password"""
|
| 157 |
user = db.query(User).filter(User.email == login_data.email).first()
|
| 158 |
+
|
| 159 |
+
# Check if user exists
|
| 160 |
+
if not user:
|
| 161 |
+
raise HTTPException(
|
| 162 |
+
status_code=status.HTTP_404_NOT_FOUND,
|
| 163 |
+
detail="Email not registered. Please create an account first.",
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
# Check if password is correct
|
| 167 |
+
if not verify_password(login_data.password, user.password_hash):
|
| 168 |
raise HTTPException(
|
| 169 |
status_code=status.HTTP_401_UNAUTHORIZED,
|
| 170 |
+
detail="Incorrect email or password. Please try again.",
|
| 171 |
headers={"WWW-Authenticate": "Bearer"},
|
| 172 |
)
|
| 173 |
|