mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
confirmation: Create render_confirmation_key_error function.
This commit is contained in:
@@ -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()
|
||||
|
17
templates/confirmation/link_does_not_exist.html
Normal file
17
templates/confirmation/link_does_not_exist.html
Normal 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 %}
|
17
templates/confirmation/link_expired.html
Normal file
17
templates/confirmation/link_expired.html
Normal 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 %}
|
20
templates/confirmation/link_malformed.html
Normal file
20
templates/confirmation/link_malformed.html
Normal 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 %}
|
Reference in New Issue
Block a user