- def post_register_confirm_redirect(self, request, node):
- messages.add_message(request, messages.INFO, 'Welcome! Please fill in some more information.')
- return HttpResponseRedirect('/%s/%s/' % (node.get_absolute_url().strip('/'), reverse('account', urlconf=self).strip('/')))
+ def post_register_confirm_redirect(self, request):
+ messages.add_message(request, messages.INFO, 'Welcome! Please fill in some more information.', fail_silently=True)
+ return HttpResponseRedirect('/%s/%s/' % (request.node.get_absolute_url().strip('/'), reverse('account', urlconf=self).strip('/')))
+
+ def email_change_confirm(self, request, extra_context=None, uidb36=None, token=None, email=None, token_generator=email_token_generator):
+ """
+ Checks that a given hash in an email change link is valid. If so, changes the email and redirects to the account page.
+ """
+ assert uidb36 is not None and token is not None and email is not None
+
+ try:
+ uid_int = base36_to_int(uidb36)
+ except:
+ raise Http404
+
+ user = get_object_or_404(User, id=uid_int)
+
+ email = '@'.join(email.rsplit('+', 1))
+
+ if email == user.email:
+ # Then short-circuit.
+ raise Http404
+
+ if token_generator.check_token(user, email, token):
+ user.email = email
+ user.save()
+ messages.add_message(request, messages.SUCCESS, 'Email changed successfully.')
+ return HttpResponseRedirect('/%s/%s/' % (request.node.get_absolute_url().strip('/'), reverse('account', urlconf=self).strip('/')))
+
+ raise Http404