Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor email confirmation pathways to use common error handling #5891

Closed
wants to merge 3 commits into from

Conversation

hackerkid
Copy link
Member

@hackerkid hackerkid commented Jul 21, 2017

Related issue #5739
@rishig Thoughts?

@hackerkid hackerkid changed the title [WIP] Refactor email confirmation pathways to use common error handling Refactor email confirmation pathways to use common error handling Jul 22, 2017
Copy link
Member

@rishig rishig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks @hackerkid! Left a few comments. Before this is merged, we'll also have to add something like

try:
    obj = get_object_from_key
except ConfirmationKeyException:
    obj = False

or similar everywhere else that get_object_from_key is called.

@@ -34,6 +36,14 @@ def __init__(self, error_type):
super(Exception, self).__init__()
self.error_type = error_type

def render_confirmation_key_error(request, ctx, exception):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use context here instead of ctx. The ctx elsewhere in the code is legacy from pre-2014.

<hr/>
<p class="lead">Whoops. We couldn't find your confirmation link in the system!</p>

{% if verbose_support_offers %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just set verbose_support_offers to True, and remove the False branch here and in the other confirmation templates.


<div class="pitch">
<hr/>
<p class="lead">Whoops. The confirmation link has expired.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this,

<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>

@@ -52,14 +52,16 @@ def generate_key():

def get_object_from_key(confirmation_key):
# type: (str) -> Union[bool, PreregistrationUser, EmailChangeStatus]
if len(confirmation_key) != 24:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be 24 or 40. Before this line, we can add a comment like # confirmation keys used to be 40 characters

try:
obj = get_object_from_key(confirmation_key)
except ConfirmationKeyException as exception:
ctx = {'verbose_support_offers': settings.VERBOSE_SUPPORT_OFFERS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed (and possibly the ctx argument from render_confirmation_key_error can be removed entirely?)

@hackerkid
Copy link
Member Author

@rishig Updated.

Copy link
Member

@rishig rishig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks @hackerkid! Noticed a few spelling things, once those are resolved this will be ready for merge.

@@ -24,6 +26,24 @@
import string
from typing import Any, Dict, Optional, Text, Union

class ConfirmationKeyException(Exception):
WORNG_LENGTH = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, just noticed this should be WRONG, instead of WORNG


<div class="pitch">
<hr/>
<p class="lead">Whoops. We couldn't find your confirmation link in the system!</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this end in a . instead of !

<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, its probably our fault. We're sorry.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its -> it's

@hackerkid
Copy link
Member Author

@rishig Fixed :)

@rishig
Copy link
Member

rishig commented Jul 26, 2017

Thanks @hackerkid!
@timabbott ready to merge from me.

@timabbott
Copy link
Sponsor Member

Merged, thanks @hackerkid!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants