Exemple #1
0
def resetPasswordToken(request):

    msg = ""
    if request.method == "POST":
        form = tokenRequestForm(request.POST)
        if form.is_valid():
            try:
                user = Company.objects.get(email = form.cleaned_data['username'])
                tokens = passwordRecovery.objects.filter(user = user)
                for obj in tokens:
                    obj.delete()
                token = passwordRecovery.objects.create(token = uuid.uuid4(), user = user)
                msg = "Am email has been send to your email address."
                # send an email with the token
                print token.token

            except Exception, err:
                print err
                form.non_field_errors = "Invalid username."
        else:
            form.non_field_errors = "Invalid data submited."
Exemple #2
0
                user = Company.objects.get(email = form.cleaned_data['username'])
                tokens = passwordRecovery.objects.filter(user = user)
                for obj in tokens:
                    obj.delete()
                token = passwordRecovery.objects.create(token = uuid.uuid4(), user = user)
                msg = "Am email has been send to your email address."
                # send an email with the token
                print token.token

            except Exception, err:
                print err
                form.non_field_errors = "Invalid username."
        else:
            form.non_field_errors = "Invalid data submited."
    else:
        form = tokenRequestForm()

    return render_to_response(  
                              'tokenRequest.html', 
                              {'form': form, "msg": msg}, 
                              context_instance=RequestContext(request)
                             )


@login_required
def index(request):    

    #send_mail('sendGrid - email', 'Greetz, this is just a test email ', '*****@*****.**', ['*****@*****.**', '*****@*****.**'], fail_silently=False)
    return render_to_response(
                              'index.html',
                              {"data":RequestContext(request).dicts[2]},