feat: def pending_url on AccountConfirmChallenge and migrate views
parent
453b115485
commit
cf7e12e33b
|
@ -48,3 +48,6 @@ class AccountConfirmChallenge(models.Model):
|
||||||
Get verification link
|
Get verification link
|
||||||
"""
|
"""
|
||||||
return reverse("accounts.verify", args=(self.challenge_text,))
|
return reverse("accounts.verify", args=(self.challenge_text,))
|
||||||
|
|
||||||
|
def pending_url(self):
|
||||||
|
return reverse("accounts.verify.pending", args=(self.public_ref,))
|
||||||
|
|
|
@ -134,11 +134,19 @@ def register_view(request):
|
||||||
password=password,
|
password=password,
|
||||||
) # TODO: get email from settings.py
|
) # TODO: get email from settings.py
|
||||||
|
|
||||||
challenge = AccountConfirmChallenge(owned_by=user)
|
challenge = None
|
||||||
challenge.save()
|
|
||||||
send_verification_email(request, challenge=challenge)
|
|
||||||
|
|
||||||
return redirect(reverse("accounts.verify.pending", args=(challenge.public_ref,)))
|
if not AccountConfirmChallenge.objects.filter(owned_by=user).exists():
|
||||||
|
challenge = AccountConfirmChallenge(owned_by=user)
|
||||||
|
challenge.save()
|
||||||
|
send_verification_email(request, challenge=challenge)
|
||||||
|
else:
|
||||||
|
challenge = AccountConfirmChallenge.objects.get(owned_by=user)
|
||||||
|
|
||||||
|
user.is_active = False
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
return redirect(challenge.pending_url())
|
||||||
|
|
||||||
|
|
||||||
def verification_pending_view(request, public_ref):
|
def verification_pending_view(request, public_ref):
|
||||||
|
@ -155,7 +163,7 @@ def verification_pending_view(request, public_ref):
|
||||||
def resend_verification_email_view(request, public_ref):
|
def resend_verification_email_view(request, public_ref):
|
||||||
challenge = get_object_or_404(AccountConfirmChallenge, public_ref=public_ref)
|
challenge = get_object_or_404(AccountConfirmChallenge, public_ref=public_ref)
|
||||||
send_verification_email(request, challenge=challenge)
|
send_verification_email(request, challenge=challenge)
|
||||||
return redirect(reverse("accounts.verify.pending", args=(challenge.public_ref,)))
|
return redirect(challenge.pending_url())
|
||||||
|
|
||||||
|
|
||||||
def verify_account(request, challenge):
|
def verify_account(request, challenge):
|
||||||
|
|
Loading…
Reference in New Issue