Exemplo n.º 1
0
def password_reset_key(request):
    d = {'clientip': request.META['REMOTE_ADDR'], 'user': request.user}
    data = getsiteandmenus(request)
    note = _("Please enter your registered email")
    if request.method == 'POST':
        email = request.POST['email']
        if email and email != "":
            try:
                user = User.objects.get(username=request.POST['email'])
                user_verification, created = UserVerification.objects.get_or_create(user=user)
                user_verification.password_reset_key = create_verification_link(user)
                user_verification.save()
                data['ruser'] = user
                data['activation_key'] = user_verification.password_reset_key
                domain = data['site'].home_url
                data['domain'] = domain.rstrip('/')
                data['recipientlist'] = [user.username]
                note = send_email_by_operation_name(data, "send_reset_password_key")
                if note:
                    note = "Parola sıfırlama e-postası adresinize gönderildi."
                else:
                    note = "E-posta gönderilemedi"
            except ObjectDoesNotExist:
                note = _("""There isn't any user record with this e-mail on the system""")
                log.error(note, extra=d)
            except Exception as e:
                note = _("""Password reset operation failed""")
                log.error(note, extra=d)
                log.error(e.message, extra=d)
        else:
            note = _("""Email field can not be empty""")
            log.error(note, extra=d)
    data['note'] = note
    return render_to_response("userprofile/change_password_key_request.html", data,
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def active_resend(request):
    data = prepare_template_data(request)
    note = _("Please activate your account.  If you want to re-send an activation email, please click following button") 
    if request.POST:
        user = request.user
        user_verification, created = UserVerification.objects.get_or_create(user_email=user.username)
        context={}
        context['user'] = user
        domain = Site.objects.get(is_active=True).home_url
        if domain.endswith('/'):
            domain = domain.rstrip('/')
        context['domain'] = domain
        
        user_verification, created = UserVerification.objects.get_or_create(user_email=user.username)
        user_verification.activation_key = create_verification_link(user)
        user_verification.save()
        context['activation_key'] = user_verification.activation_key
        try:
            send_email("userprofile/messages/send_confirm_subject.html",
                            "userprofile/messages/send_confirm.html",
                            "userprofile/messages/send_confirm.text",
                            context,
                            settings.EMAIL_FROM_ADDRESS,
                            [user.username])

            note = _("Your activation link has been sent to your email address")
        except Exception as e:
            note = e.message
    data['note'] = note
    return render_to_response("userprofile/activate_resend.html", data, context_instance=RequestContext(request))
Exemplo n.º 3
0
def active_resend(request):
    data = prepare_template_data(request)
    note = _(
        "Please activate your account.  If you want to re-send an activation email, please click following button"
    )
    if request.POST:
        user = request.user
        user_verification, created = UserVerification.objects.get_or_create(
            user_email=user.username)
        context = {}
        context['user'] = user
        domain = Site.objects.get(is_active=True).home_url
        if domain.endswith('/'):
            domain = domain.rstrip('/')
        context['domain'] = domain

        user_verification, created = UserVerification.objects.get_or_create(
            user_email=user.username)
        user_verification.activation_key = create_verification_link(user)
        user_verification.save()
        context['activation_key'] = user_verification.activation_key
        try:
            send_email("userprofile/messages/send_confirm_subject.html",
                       "userprofile/messages/send_confirm.html",
                       "userprofile/messages/send_confirm.text", context,
                       settings.EMAIL_FROM_ADDRESS, [user.username])

            note = _(
                "Your activation link has been sent to your email address")
        except Exception as e:
            note = e.message
    data['note'] = note
    return render_to_response("userprofile/activate_resend.html",
                              data,
                              context_instance=RequestContext(request))
Exemplo n.º 4
0
def send_confirm_link(instance, created, **kwargs):
    if not instance.is_staff:
        if created:
            instance.is_active = False
            user_verification, created = UserVerification.objects.get_or_create(user=instance)
            user_verification.activation_key = create_verification_link(instance)
            user_verification.save()
            context = {'user': instance, 'activation_key': user_verification.activation_key,
                       'site': Site.objects.get(is_active=True), 'recipientlist': [instance.username]}
            context['domain'] = context['site'].home_url.rstrip('/')
            send_email_by_operation_name(context, "send_activation_key")
Exemplo n.º 5
0
def active_resend(request):
    data = getsiteandmenus(request)
    note = _("Please activate your account.  If you want to re-send an activation email, please click following button")
    if request.POST:
        domain = data['site'].home_url
        data['domain'] = domain.rstrip('/')
        user_verification, created = UserVerification.objects.get_or_create(user=request.user)
        user_verification.activation_key = create_verification_link(request.user)
        user_verification.save()
        data['activation_key'] = user_verification.activation_key
        data['recipientlist'] = [request.user.username]
        note = send_email_by_operation_name(data, "send_activation_key")
    data['note'] = note
    return render_to_response("userprofile/activate_resend.html", data, context_instance=RequestContext(request))
Exemplo n.º 6
0
def send_confirm_link(instance, created, **kwargs):
    if not instance.is_staff:
        if created:
            instance.is_active = False
            user_verification, created = UserVerification.objects.get_or_create(user=instance)
            user_verification.activation_key = create_verification_link(instance)
            user_verification.save()
            context = {
                "user": instance,
                "activation_key": user_verification.activation_key,
                "site": Site.objects.get(is_active=True),
                "recipientlist": [instance.username],
            }
            context["domain"] = context["site"].home_url.rstrip("/")
            send_email_by_operation_name(context, "send_activation_key")
Exemplo n.º 7
0
def password_reset_key(request):
    d = {'clientip': request.META['REMOTE_ADDR'], 'user': request.user}
    data = prepare_template_data(request)
    note = _("Please enter your registered email")
    if request.method == 'POST':
        email = request.POST['email']
        if email and email != "":
            try:
                user = User.objects.get(username=request.POST['email'])
                user_verification, created = UserVerification.objects.get_or_create(
                    user_email=user.username)
                user_verification.password_reset_key = create_verification_link(
                    user)
                user_verification.save()
                context = {}
                context['user'] = user
                context[
                    'activation_key'] = user_verification.password_reset_key
                domain = Site.objects.get(is_active=True).home_url
                if domain.endswith('/'):
                    domain = domain.rstrip('/')
                context['domain'] = domain
                send_email(
                    "userprofile/messages/send_reset_password_key_subject.html",
                    "userprofile/messages/send_reset_password_key.html",
                    "userprofile/messages/send_reset_password_key.text",
                    context, settings.EMAIL_FROM_ADDRESS, [user.username])
                note = _("""Password reset key has been sent""")
            except ObjectDoesNotExist:
                note = _(
                    """There isn't any user record with this e-mail on the system"""
                )
                log.error(note, extra=d)
            except Exception as e:
                note = _("""Password reset operation failed""")
                log.error(note, extra=d)
                log.error(e.message, extra=d)
        else:
            note = _("""Email field can not be empty""")
            log.error(note, extra=d)
    data['note'] = note
    return render_to_response("userprofile/change_password_key_request.html",
                              data,
                              context_instance=RequestContext(request))
Exemplo n.º 8
0
def active_resend(request):
    data = {
        "note":
        _("Please activate your account.  If you want to re-send an activation email, please click following button"
          )
    }
    if request.POST:
        domain = request.site.home_url
        data['domain'] = domain.rstrip('/')
        user_verification, created = UserVerification.objects.get_or_create(
            user=request.user)
        user_verification.activation_key = create_verification_link(
            request.user)
        user_verification.save()
        data['activation_key'] = user_verification.activation_key
        data['recipientlist'] = [request.user.username]
        data["note"] = send_email_by_operation_name(data,
                                                    "send_activation_key")
    return render(request, "userprofile/activate_resend.html", data)
Exemplo n.º 9
0
def password_reset_key(request):
    d = {'clientip': request.META['REMOTE_ADDR'], 'user': request.user}
    data = prepare_template_data(request)
    note = _("Please enter your registered email")
    if request.method == 'POST':
        email = request.POST['email']
        if email and email != "":
            try:
                user = User.objects.get(username=request.POST['email'])
                user_verification, created = UserVerification.objects.get_or_create(user_email=user.username)
                user_verification.password_reset_key = create_verification_link(user)
                user_verification.save()
                context = {}
                context['user'] = user
                context['activation_key'] = user_verification.password_reset_key
                domain = Site.objects.get(is_active=True).home_url
                if domain.endswith('/'):
                    domain = domain.rstrip('/')
                context['domain'] = domain
                send_email("userprofile/messages/send_reset_password_key_subject.html",
                                "userprofile/messages/send_reset_password_key.html",
                                "userprofile/messages/send_reset_password_key.text",
                                context,
                                settings.EMAIL_FROM_ADDRESS,
                                [user.username]) 
                note = _("""Password reset key has been sent""")
            except ObjectDoesNotExist:
                note=_("""There isn't any user record with this e-mail on the system""") 
                log.error(note, extra=d)
            except Exception as e:
                note = _("""Password reset operation failed""")
                log.error(note, extra=d)
                log.error(e.message, extra=d)
        else:
            note = _("""Email field can not be empty""")    
            log.error(note, extra=d)
    data['note'] = note
    return render_to_response("userprofile/change_password_key_request.html", data, context_instance=RequestContext(request))
Exemplo n.º 10
0
def password_reset_key(request):
    data = {'note': _("Please enter your registered email")}
    if request.method == 'POST':
        email = request.POST['email']
        if email and email != "":
            try:
                user = User.objects.get(username=request.POST['email'])
                user_verification, created = UserVerification.objects.get_or_create(
                    user=user)
                user_verification.password_reset_key = create_verification_link(
                    user)
                user_verification.save()
                data['ruser'] = user
                data['activation_key'] = user_verification.password_reset_key
                domain = request.site.home_url
                data['domain'] = domain.rstrip('/')
                data['recipientlist'] = [user.username]
                data['note'] = send_email_by_operation_name(
                    data, "send_reset_password_key")
                if data['note']:
                    data[
                        'note'] = "Parola sıfırlama e-postası adresinize gönderildi."
                else:
                    data['note'] = "E-posta gönderilemedi"
            except ObjectDoesNotExist:
                data['note'] = _(
                    """There isn't any user record with this e-mail on the system"""
                )
                log.error(data['note'], extra=request.log_extra)
            except Exception as e:
                data['note'] = _("""Password reset operation failed""")
                log.error(data['note'], extra=request.log_extra)
                log.error(e.message, extra=request.log_extra)
        else:
            data['note'] = _("""Email field can not be empty""")
            log.error(data['note'], extra=request.log_extra)
    return render(request, "userprofile/change_password_key_request.html",
                  data)
Exemplo n.º 11
0
def send_confirm_link(sender, instance, created, **kwargs):
    if not instance.is_staff:
        if created:
            instance.is_active=False
            user_verification, created = UserVerification.objects.get_or_create(user_email=instance.username)
            user_verification.activation_key = create_verification_link(instance)
            user_verification.save()
            context={}
            context['user'] = instance
            context['activation_key'] = user_verification.activation_key
            domain = Site.objects.get(is_active=True).home_url
            if domain.endswith('/'):
                 domain = domain.rstrip('/')
            context['domain'] = domain
            try:
                send_email("userprofile/messages/send_confirm_subject.html",
                       "userprofile/messages/send_confirm.html",
                       "userprofile/messages/send_confirm.text",
                       context,
                       EMAIL_FROM_ADDRESS,
                       [instance.username])
            except:
                 log.error(("%s account has been created but has been failed send email verification link") % (instance.username),extra={'clientip':'','user':''})