forked from Hostea/dashboard
feat: def pending_url on AccountConfirmChallenge and migrate views
parent
453b115485
commit
cf7e12e33b
|
@ -48,3 +48,6 @@ class AccountConfirmChallenge(models.Model):
|
|||
Get verification link
|
||||
"""
|
||||
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,
|
||||
) # TODO: get email from settings.py
|
||||
|
||||
challenge = None
|
||||
|
||||
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)
|
||||
|
||||
return redirect(reverse("accounts.verify.pending", args=(challenge.public_ref,)))
|
||||
user.is_active = False
|
||||
user.save()
|
||||
|
||||
return redirect(challenge.pending_url())
|
||||
|
||||
|
||||
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):
|
||||
challenge = get_object_or_404(AccountConfirmChallenge, public_ref=public_ref)
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue