def forgot_action(request):
    Form = UsersForgotMail(request.POST)
    Dict = {}
    if Form.is_valid():
        # Save a new Article object from the form's data.

        SessionLink = generate_key("hold")[10:30]
        reset_link = ResetPwdLink(user=Form.user, key=SessionLink)
        reset_link.save()
        # if settings.DEBUG is False:
        Email = Form.cleaned_data["email"]

        main.msgs.send_mail(
            _(u"Обновление пароля на бирже " + settings.BASE_HOST),
            reset_pwd_mail(Form.user, SessionLink),
            settings.EMAIL_HOST_USER,
            [Email],
            fail_silently=False,
        )

        return redirect("/forgot_success")
    else:
        t = loader.get_template("simple_form_center.html")
        Dict["title"] = settings.secondary_main_forgot
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = settings.common_help_text
        Dict["action"] = "/forgot_action"
        Dict["action_title"] = settings.reset_password_title
        return http_tmpl_context(request, t, Dict)
def forgot_action(request):
    Form = UsersForgotMail(request.POST)
    Dict = {}
    if Form.is_valid():
        # Save a new Article object from the form's data.

        SessionLink = generate_key("hold")[10:30]
        reset_link = ResetPwdLink(user=Form.user, key=SessionLink)
        reset_link.save()
        # if settings.DEBUG is False:
        Email = Form.cleaned_data["email"]

        main.msgs.send_mail(_(u'Обновление пароля на бирже ' + settings.BASE_HOST),
                            reset_pwd_mail(Form.user, SessionLink),
                            [Email],
                            fail_silently=False)

        return redirect("/forgot_success")
    else:
        t = loader.get_template("simple_form_center.html")
        Dict["title"] = settings.secondary_main_forgot
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = settings.common_help_text
        Dict["action"] = "/forgot_action"
        Dict["action_title"] = settings.reset_password_title
        return http_tmpl_context(request, t, Dict)
示例#3
0
def forgot_action(request):
    Form = UsersForgotMail(request.POST)  
    Dict = {}
    if Form.is_valid():
# Save a new Article object from the form's data.
        hold = HoldsWithdraw(user = Form.user, hours =  settings.default_hold)
        hold.save()
        NewPwd = generate_key("hold")[10:30]
        #if settings.DEBUG is False:
        Email = Form.cleaned_data["email"]
        send_mail(_(u'Обновление пароля на сайте ' + settings.BASE_HOST),
                                   reset_pwd_mail(Form.user, NewPwd),
                                   settings.EMAIL_HOST_USER,
                                   [ Email ],
                                     fail_silently = False)       
                
        Form.user.set_password(NewPwd)
        Form.user.save()        
        return redirect("/forgot_success")                
    else :
        t = loader.get_template("simple_form.html")   
        Dict["title"] = settings.secondary_main_forgot    
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = settings.common_help_text   
        Dict["action"] = "/forgot_action"
        Dict["action_title"] = settings.reset_password_title
        return http_tmpl_context(request, t, Dict)    
def forgot(Req):
    t = loader.get_template("simple_form_center.html")
    Dict = {}
    Dict["title"] = settings.secondary_main_forgot
    forgotForm = UsersForgotMail()
    Dict["form"] = forgotForm.as_p()
    Dict["common_help_text"] = settings.common_help_text
    Dict["action"] = "/forgot_action"
    Dict["action_title"] = settings.reset_password_title
    return http_tmpl_context(Req, t, Dict)
def forgot(Req):
    t = loader.get_template("simple_form_center.html")
    Dict = {}
    Dict["title"] = settings.secondary_main_forgot
    forgotForm = UsersForgotMail()
    Dict["form"] = forgotForm.as_p()
    Dict["common_help_text"] = settings.common_help_text
    Dict["action"] = "/forgot_action"
    Dict["action_title"] = settings.reset_password_title
    return http_tmpl_context(Req, t, Dict)