confirmation: Create render_confirmation_key_error function.

This commit is contained in:
Vishnu Ks
2017-07-22 03:55:41 +05:30
committed by Tim Abbott
parent b0ed7915a9
commit 65ad72a674
4 changed files with 64 additions and 0 deletions

View File

@@ -14,6 +14,8 @@ from django.conf import settings
from django.contrib.sites.models import Site
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.utils.timezone import now as timezone_now
from zerver.lib.send_email import send_email
@@ -34,6 +36,14 @@ class ConfirmationKeyException(Exception):
super(Exception, self).__init__()
self.error_type = error_type
def render_confirmation_key_error(request, exception):
# type: (HttpRequest, ConfirmationKeyException) -> HttpResponse
if exception.error_type == ConfirmationKeyException.WRONG_LENGTH:
return render(request, 'confirmation/link_malformed.html')
if exception.error_type == ConfirmationKeyException.EXPIRED:
return render(request, 'confirmation/link_expired.html')
return render(request, 'confirmation/link_does_not_exist.html')
def generate_key():
# type: () -> str
generator = SystemRandom()

View File

@@ -0,0 +1,17 @@
{% extends "zerver/portico.html" %}
{% block portico_content %}
<div class="pitch">
<hr/>
<p class="lead">Whoops. We couldn't find your confirmation link in the system.</p>
<p>
Anyway, shoot us a line at
<a href="mailto:{{ support_email }}">{{ support_email }}</a>
and we'll get this resolved shortly.
</p>
</div>
{% endblock %}

View File

@@ -0,0 +1,17 @@
{% extends "zerver/portico.html" %}
{% block portico_content %}
<div class="pitch">
<hr/>
<p class="lead">Whoops. The confirmation link has expired.</p>
<p>
If you're not sure how to generate a new one, shoot us a line at
<a href="mailto:{{ support_email }}">{{ support_email }}</a>
and we'll get this resolved shortly.
</p>
</div>
{% endblock %}

View File

@@ -0,0 +1,20 @@
{% extends "zerver/portico.html" %}
{% block portico_content %}
<div class="pitch">
<hr/>
<p class="lead">Whoops. The confirmation link is malformed.</p>
<p>Make sure you copied the link correctly in to your browser. If you're
still encountering this page, it's probably our fault. We're sorry.</p>
<p>
Anyway, shoot us a line at
<a href="mailto:{{ support_email }}">{{ support_email }}</a>
and we'll get this resolved shortly.
</p>
</div>
{% endblock %}