diff --git a/bookwyrm/templates/confirm_email/confirm_email.html b/bookwyrm/templates/confirm_email/confirm_email.html index 8c8adcdd..65d40829 100644 --- a/bookwyrm/templates/confirm_email/confirm_email.html +++ b/bookwyrm/templates/confirm_email/confirm_email.html @@ -29,9 +29,14 @@
- {% trans "Can't find your code?" as button_text %} - {% include "snippets/toggle/open_button.html" with text=button_text controls_text="resend_form" focus="resend_form_header" %} - {% include "confirm_email/resend_form.html" with controls_text="resend_form" %} + + {% include "confirm_email/resend_modal.html" with id="resend_form" %}
diff --git a/bookwyrm/templates/confirm_email/resend.html b/bookwyrm/templates/confirm_email/resend.html new file mode 100644 index 00000000..0b5ded06 --- /dev/null +++ b/bookwyrm/templates/confirm_email/resend.html @@ -0,0 +1,10 @@ +{% extends 'landing/layout.html' %} +{% load i18n %} + +{% block title %} +{% trans "Resend confirmation link" %} +{% endblock %} + +{% block content %} +{% include "confirm_email/resend_modal.html" with active=True static=True %} +{% endblock %} diff --git a/bookwyrm/templates/confirm_email/resend_form.html b/bookwyrm/templates/confirm_email/resend_form.html deleted file mode 100644 index 7c0c1098..00000000 --- a/bookwyrm/templates/confirm_email/resend_form.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "components/inline_form.html" %} -{% load i18n %} -{% block header %} -{% trans "Resend confirmation link" %} -{% endblock %} - -{% block form %} -
- {% csrf_token %} -
- -
- -
-
-
- -
-
-{% endblock %} diff --git a/bookwyrm/templates/confirm_email/resend_modal.html b/bookwyrm/templates/confirm_email/resend_modal.html new file mode 100644 index 00000000..713fe644 --- /dev/null +++ b/bookwyrm/templates/confirm_email/resend_modal.html @@ -0,0 +1,42 @@ +{% extends "components/modal.html" %} +{% load i18n %} + +{% block modal-title %} +{% trans "Resend confirmation link" %} +{% endblock %} + +{% block modal-form-open %} +
+{% endblock %} + +{% block modal-body %} +{% csrf_token %} +
+ +
+ +
+

+ {% trans "No user matching this email address found." %} +

+
+
+
+{% endblock %} + +{% block modal-footer %} +
+ +
+{% endblock %} + +{% block modal-form-close %} +
+{% endblock %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 040b479c..d73327f1 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -71,7 +71,7 @@ urlpatterns = [ views.ConfirmEmailCode.as_view(), name="confirm-email-code", ), - re_path(r"^resend-link/?$", views.resend_link, name="resend-link"), + re_path(r"^resend-link/?$", views.ResendConfirmEmail.as_view(), name="resend-link"), re_path(r"^logout/?$", views.Logout.as_view(), name="logout"), re_path( r"^password-reset/?$", diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 36423fee..eadf423d 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -52,7 +52,8 @@ from .books.links import BookFileLinks, AddFileLink, delete_link from .landing.about import about, privacy, conduct from .landing.landing import Home, Landing from .landing.login import Login, Logout -from .landing.register import Register, ConfirmEmail, ConfirmEmailCode, resend_link +from .landing.register import Register +from .landing.register import ConfirmEmail, ConfirmEmailCode, ResendConfirmEmail from .landing.password import PasswordResetRequest, PasswordReset # shelves diff --git a/bookwyrm/views/landing/register.py b/bookwyrm/views/landing/register.py index 86cd96ea..681ce0a5 100644 --- a/bookwyrm/views/landing/register.py +++ b/bookwyrm/views/landing/register.py @@ -5,7 +5,6 @@ from django.shortcuts import get_object_or_404, redirect from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.views import View -from django.views.decorators.http import require_POST from django.views.decorators.debug import sensitive_variables, sensitive_post_parameters from bookwyrm import emailing, forms, models @@ -129,12 +128,21 @@ class ConfirmEmail(View): return ConfirmEmailCode().get(request, code) -@require_POST -def resend_link(request): - """resend confirmation link""" - email = request.POST.get("email") - user = get_object_or_404(models.User, email=email) - emailing.email_confirmation_email(user) - return TemplateResponse( - request, "confirm_email/confirm_email.html", {"valid": True} - ) +class ResendConfirmEmail(View): + """you probably didn't get the email because celery is slow but you can try this""" + def get(self, request, error=False): + """resend link landing page""" + return TemplateResponse(request, "confirm_email/resend.html", {"error": error}) + + def post(self, request): + """resend confirmation link""" + email = request.POST.get("email") + try: + user = models.User.objects.get(email=email) + except models.User.DoesNotExist: + return self.get(request, error=True) + + emailing.email_confirmation_email(user) + return TemplateResponse( + request, "confirm_email/confirm_email.html", {"valid": True} + )