-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #942 from MikeSoft007/bugfix/waitlist_email
Bugfix: implement rate limiting for auth endpoints
- Loading branch information
Showing
12 changed files
with
376 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block title %}Welcome{% endblock %} | ||
|
||
{% block content %} | ||
<table role="presentation" width="100%" style="padding: 3.5rem;"> | ||
<tr> | ||
<td> | ||
<div style="text-align: center; margin-bottom: 1.5rem;"> | ||
<h1 style="font-size: 1.5rem; color: #0A0A0A; font-weight: 600;">Welcome to Boilerplate Waitlist</h1> | ||
<p style="font-size: 1.125rem; color: rgba(0, 0, 0, 0.8); font-weight: 500;">Thanks for signing up</p> | ||
</div> | ||
|
||
<div> | ||
<p style="color: #111; font-size: 1.125rem; font-weight: 600;">Hi {{name}}</p> | ||
<p style="color: rgba(17, 17, 17, 0.9); font-weight: 400;">We're thrilled to have you join our waitlist. Experience quality and innovation | ||
like never before. Our product is made to fit your needs and make your | ||
life easier.</p> | ||
</div> | ||
|
||
<div style="margin-bottom: 1.75rem;"> | ||
<h3 style="color: #0A0A0A; font-weight: 600;">Here's what you can look forward to.</h3> | ||
<div style="margin-bottom: 1.25rem;"> | ||
<ul> | ||
<li> | ||
<span style="font-weight: 600;">Exclusive Offers:</span> Enjoy special promotions and | ||
discounts available only to our members. | ||
</li> | ||
<li> | ||
<span style="font-weight: 600;">Exclusive Offers:</span> Enjoy special promotions and | ||
discounts available only to our members. | ||
</li> | ||
<li> | ||
<span style="font-weight: 600;">Exclusive Offers:</span> Enjoy special promotions and | ||
discounts available only to our members. | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<a href="{{cta_link}}" style="display: block; width: fit-content; padding: 0.5rem 2.5rem; background-color: #F97316; color: white; text-decoration: none; border-radius: 0.5rem; margin: 0 auto; text-align: center;"> | ||
Learn more about us | ||
</a> | ||
|
||
<!-- <div style="margin-top: 2rem;"> | ||
<p style="color: #111; font-size: 0.875rem; font-weight: 500;">Thank you for joining Boilerplate</p> | ||
</div> --> | ||
|
||
<div style="margin-top: 2rem;"> | ||
<p>Regards,</p> | ||
<p>Boilerplate</p> | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from fastapi import FastAPI, HTTPException | ||
from pydantic import BaseModel, EmailStr | ||
from aiosmtplib import send | ||
from email.message import EmailMessage | ||
|
||
app = FastAPI() | ||
|
||
# Email configuration | ||
EMAIL = "[email protected]" | ||
PASSWORD = "j*orWasSatc^TrdT7k7BGZ#" | ||
SMTP_HOST = "work.timbu.cloud" | ||
SMTP_PORT = 465 | ||
|
||
# Define a Pydantic model for the request body | ||
class EmailRequest(BaseModel): | ||
to_email: EmailStr | ||
subject: str = "Test Email" | ||
body: str = "This is a test email from FastAPI" | ||
|
||
|
||
|
||
@app.post("/send-tinbu-mail") | ||
async def send_email(email_request: EmailRequest): | ||
# Create the email message | ||
message = EmailMessage() | ||
message["From"] = EMAIL | ||
message["To"] = email_request.to_email | ||
message["Subject"] = email_request.subject | ||
message.set_content(email_request.body) | ||
|
||
# SMTP configuration | ||
smtp_settings = { | ||
"hostname": SMTP_HOST, | ||
"port": SMTP_PORT, | ||
"username": EMAIL, | ||
"password": PASSWORD, | ||
"use_tls": True, # Use SSL/TLS for secure connection | ||
} | ||
|
||
try: | ||
# Send the email | ||
await send(message, **smtp_settings) | ||
return {"message": f"Email sent to {email_request.to_email} successfully"} | ||
except Exception as e: | ||
raise HTTPException(status_code=500, detail=f"Failed to send email: {str(e)}") |
Oops, something went wrong.