Skip to content

Commit

Permalink
Merge pull request #193 from DocShow-AI/fix_register
Browse files Browse the repository at this point in the history
Fix register
  • Loading branch information
liberty-rising authored Jan 14, 2024
2 parents f54d28d + fbb0ed4 commit ec7a7a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/routes/user_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,21 @@ async def reset_password(request: ResetPasswordRequest):
async def send_verification_email(
request: SendVerificationEmailRequest, background_tasks: BackgroundTasks
):
print("Getting user by email")
with DatabaseManager() as session:
user_manager = UserManager(session)
user = user_manager.get_user_by_email(request.email)
if not user:
raise HTTPException(status_code=404, detail="User not found")

print("Generating verification token")
# Generate a verification token and save it in the database
token = generate_email_verification_token(user.email)
user_manager.update_user_verification_token(
username=user.username, verification_token=token
)

print("Sending verification email")
# Add a background task to send the email
background_tasks.add_task(
send_verification_email_with_sendgrid, user.email, token
Expand Down
3 changes: 3 additions & 0 deletions backend/utils/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ async def send_verification_email_with_sendgrid(email: List[str], token: str):
)
# Disable click tracking in development
# if APP_ENV == "dev":
print("Disabling click tracking")
message.tracking_settings = TrackingSettings()
message.tracking_settings.click_tracking = ClickTracking(False, False)
try:
print("Sending email")
sg = SendGridAPIClient(SENDGRID_API_KEY)
print("Sending email")
response = await sg.send(message)
print(response.status_code)
print(response.body)
Expand Down

0 comments on commit ec7a7a3

Please sign in to comment.