apps.lyric.views now generates a token associated w. the user-entered email & includes a link w. the token to login to the testserver; .tests.test_views asserts the association and the inclusion

This commit is contained in:
Disco DeDisco
2026-01-30 17:52:44 -05:00
parent bab0b045b0
commit 2d61506a6d
2 changed files with 28 additions and 1 deletions

View File

@@ -1,13 +1,20 @@
from django.contrib import messages
from django.core.mail import send_mail
from django.shortcuts import redirect
from django.urls import reverse
from .models import Token
from ..dashboard.forms import ItemForm
def send_login_email(request):
email = request.POST["email"]
token = Token.objects.create(email=email)
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(
"A magic login link to your Dashboard",
"Use this magic link to login to your Dashboard",
message_body,
"adman@howdy.earthmanrpg.me",
[email],
)