예제 #1
0
def email_verify(request, email_pk):
    email_address = get_object_or_404(EmailAddress, pk=email_pk)
    if email_address.is_verified():
        messages.error(request, "Email address was already verified.")
    if not email_address.user == request.user and not request.user.is_staff:
        messages.error(request, "You are not authorized to verify this email address")

    # Send the verification link if that was requested
    if 'send_link' in request.GET:
        email.send_verification(email_address)

    verif_key = request.GET.get('verif_key', "").strip()
    if len(verif_key) != 0:
        if email_address.verif_key == verif_key:
            # Looks good!  Mark as verified
            email_address.remote_addr = request.META.get('REMOTE_ADDR')
            email_address.remote_host = request.META.get('REMOTE_HOST')
            email_address.verified_ts = timezone.now()
            email_address.save()
            messages.success(request, "Email address has been verified.")

            if 'NEXT_URL' in request.GET:
                next_url = request.GET.get('NEXT_URL')
            elif 'HTTP_REFERER' in request.META:
                next_url = request.META['HTTP_REFERER']
            else:
                next_url = reverse('member_profile', kwargs={'username': email_address.user.username})
            return HttpResponseRedirect(next_url)
        else:
            messages.error(request, "Invalid Key")

    return render_to_response("email_verify.html", {'email':email_address.email}, context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: switchdin/nadine
def email_verify(request, email_pk):
    email_address = get_object_or_404(EmailAddress, pk=email_pk)
    if email_address.is_verified():
        messages.error(request, "Email address was already verified.")
    if not email_address.user == request.user and not request.user.is_staff:
        messages.error(request,
                       "You are not authorized to verify this email address")

    # Send the verification link if that was requested
    if 'send_link' in request.GET:
        email.send_verification(email_address)

    verif_key = request.GET.get('verif_key', "").strip()
    if len(verif_key) != 0:
        if email_address.verif_key == verif_key:
            # Looks good!  Mark as verified
            email_address.remote_addr = request.META.get('REMOTE_ADDR')
            email_address.remote_host = request.META.get('REMOTE_HOST')
            email_address.verified_ts = timezone.now()
            email_address.save()
            messages.success(request, "Email address has been verified.")
            return HttpResponseRedirect(
                reverse('member:profile:view',
                        kwargs={'username': email_address.user.username}))
        else:
            messages.error(request, "Invalid Key")

    return render(request, "email_verify.html", {'email': email_address.email})
예제 #3
0
 def save(self, verify=True, *args, **kwargs):
     """Save this EmailAddress object."""
     if not self.verif_key:
         self.generate_verif_key()
     if verify and not self.pk:
         # Skip verification if this is an update
         verify = True
     else:
         verify = False
     super(EmailAddress, self).save(*args, **kwargs)
     if verify:
         email.send_verification(self)
예제 #4
0
 def save(self, verify=True, *args, **kwargs):
     """Save this EmailAddress object."""
     if not self.verif_key:
         self.generate_verif_key()
     if verify and not self.pk:
         # Skip verification if this is an update
         verify = True
     else:
         verify = False
     super(EmailAddress, self).save(*args, **kwargs)
     if verify:
         email.send_verification(self)