Use environment variable to set sender email of auth link emails (#907)

Set sender email using `RESEND_EMAIL` environment variable for magic link sent via Resend API for authentication . It was previously hard-coded. This prevented hosting Khoj on other domains. 

Resolves #908
This commit is contained in:
Brian Kanya 2024-09-12 21:48:11 -04:00 committed by GitHub
parent 26ca3df605
commit 1d512b4986
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,7 +44,12 @@ async def send_magic_link_email(email, unique_id, host):
html_content = template.render(link=f"{host}auth/magic?code={unique_id}")
resend.Emails.send(
{"sender": "noreply@khoj.dev", "to": email, "subject": "Your Sign-In Link for Khoj 🚀", "html": html_content}
{
"sender": os.environ.get("RESEND_EMAIL", "noreply@khoj.dev"),
"to": email,
"subject": "Your Sign-In Link for Khoj 🚀",
"html": html_content,
}
)