This commit is contained in:
parent
d0b672ac15
commit
a0c556f879
@ -160,16 +160,14 @@ def reset_password(request: ResetPasswordRequest, db: Session = Depends(get_db))
|
|||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail="User not found",
|
detail="User not found",
|
||||||
Send PIN via email
|
)
|
||||||
email_sent = send_password_reset_pin(request.email, pin, expires_minutes=15)
|
|
||||||
|
|
||||||
if not email_sent:
|
# Update password
|
||||||
# If email sending fails, still print to console for development
|
user.hashed_password = get_password_hash(request.new_password)
|
||||||
print(f"\n⚠️ Email not sent. Password Reset PIN for {request.email}: {pin}")
|
db.commit()
|
||||||
print(f"Expires at: {user.pin_expires_at}\n")
|
|
||||||
|
return {"message": "Password reset successful"}
|
||||||
|
|
||||||
return {
|
|
||||||
"message": "If the email exists, a PIN has been sent to your email",
|
|
||||||
|
|
||||||
@router.post("/request-reset-pin")
|
@router.post("/request-reset-pin")
|
||||||
def request_reset_pin(request: RequestPinRequest, db: Session = Depends(get_db)):
|
def request_reset_pin(request: RequestPinRequest, db: Session = Depends(get_db)):
|
||||||
@ -189,14 +187,16 @@ def request_reset_pin(request: RequestPinRequest, db: Session = Depends(get_db))
|
|||||||
user.pin_expires_at = datetime.utcnow() + timedelta(minutes=15)
|
user.pin_expires_at = datetime.utcnow() + timedelta(minutes=15)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
# TODO: Send PIN via email
|
# Send PIN via email
|
||||||
# For now, print it (REMOVE IN PRODUCTION)
|
email_sent = send_password_reset_pin(request.email, pin, expires_minutes=15)
|
||||||
print(f"\n✅ Password Reset PIN for {request.email}: {pin}")
|
|
||||||
|
if not email_sent:
|
||||||
|
# If email sending fails, still print to console for development
|
||||||
|
print(f"\n⚠️ Email not sent. Password Reset PIN for {request.email}: {pin}")
|
||||||
print(f"Expires at: {user.pin_expires_at}\n")
|
print(f"Expires at: {user.pin_expires_at}\n")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "If the email exists, a PIN has been sent",
|
"message": "If the email exists, a PIN has been sent to your email",
|
||||||
"pin": pin # REMOVE IN PRODUCTION - only for testing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -35,9 +35,9 @@ backend:
|
|||||||
# Email configuration for password reset (optional)
|
# Email configuration for password reset (optional)
|
||||||
SMTP_HOST: "smtp.gmail.com"
|
SMTP_HOST: "smtp.gmail.com"
|
||||||
SMTP_PORT: "587"
|
SMTP_PORT: "587"
|
||||||
SMTP_USERNAME: ""
|
SMTP_USERNAME: "dvirlabs@gmail.com"
|
||||||
SMTP_PASSWORD: ""
|
SMTP_PASSWORD: "tlet bebr jwbe amzw"
|
||||||
SMTP_FROM: "noreply@brand-master.com"
|
SMTP_FROM: "dvirlabs@gmail.com"
|
||||||
|
|
||||||
# JWT Secret Key (IMPORTANT: Change this in production!)
|
# JWT Secret Key (IMPORTANT: Change this in production!)
|
||||||
jwtSecretKey: "your-secret-key-change-this-in-production"
|
jwtSecretKey: "your-secret-key-change-this-in-production"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user