offloaded some apps.lyric.views responsibilities to new Celery depend fn in .tasks; core.celery created for celery config; CELERY_BROKER_URL added to .settings & throughout project; some lyric view IT responsibility now accordingly covered by task UT domain
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import requests
|
||||
from django.contrib import auth, messages
|
||||
from django.conf import settings
|
||||
# from django.core.mail import send_mail
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse
|
||||
|
||||
from .models import Token
|
||||
from .tasks import send_login_email_task
|
||||
|
||||
|
||||
def send_login_email(request):
|
||||
email = request.POST["email"]
|
||||
@@ -12,26 +12,13 @@ def send_login_email(request):
|
||||
url = request.build_absolute_uri(
|
||||
reverse("login") + "?token=" + str(token.uid),
|
||||
)
|
||||
message_body = f"Use this magic link to login to your Dashboard:\n\n{url}"
|
||||
# Send mail via Mailgun HTTP API
|
||||
response = requests.post(
|
||||
f"https://api.mailgun.net/v3/{settings.MAILGUN_DOMAIN}/messages",
|
||||
auth=("api", settings.MAILGUN_API_KEY),
|
||||
data={
|
||||
"from": "adman@howdy.earthmanrpg.com",
|
||||
"to": email,
|
||||
"subject": "A magic login link to your Dashboard",
|
||||
"text": message_body,
|
||||
},
|
||||
)
|
||||
# Log any errors
|
||||
if response.status_code != 200:
|
||||
print(f"Mailgun API error: {response.status_code}: {response.text}")
|
||||
|
||||
send_login_email_task.delay(email, url)
|
||||
messages.success(
|
||||
request,
|
||||
"Check your email!—there you'll find a magic login link. But hurry… it's only temporary!",
|
||||
)
|
||||
|
||||
return redirect("/")
|
||||
|
||||
def login(request):
|
||||
|
||||
Reference in New Issue
Block a user