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:
@@ -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],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user