def registration_confirm(request, uidb36, token): """ Check the hash in a link the user clicked and activate account """ try: uid_int = base36_to_int(uidb36) user = User.objects.get(id=uid_int) except (ValueError, User.DoesNotExist): user = None registration_token_generator = TokenGenerator(settings.REGISTRATION_TIMEOUT_DAYS) if (user is not None) and registration_token_generator.check_token(user, token): user.is_active = True user.save() return HttpResponseRedirect(reverse('registration_complete')) else: return HttpResponseRedirect(reverse('registration_failed'))
def email_change_confirm(request, uidb36, token): """ Change the primary email in the case if the hash in the link the user clicked was correct """ email_change_token_generator = TokenGenerator(settings.EMAIL_CHANGE_TIMEOUT_DAYS) try: uid_int = base36_to_int(uidb36) user = User.objects.get(id=uid_int) except (ValueError, User.DoesNotExist): user = None if (user is not None) and email_change_token_generator.check_token(user, token): profile = user.get_profile() user.email = profile.temporary_email user.save() return HttpResponseRedirect(reverse('email_change_complete')) else: return HttpResponseRedirect(reverse('email_change_failed'))