Exemplo n.º 1
0
def lost_password(request):
    """Help users with forgotten passwords."""
    form = PasswordRequestForm()

    if request.method == 'POST' and form.validate(request.form):
        reset_request = form.create_request()
        db.commit()
        text = render_template('notifications/lost_password.txt',
                               req_id=reset_request.req_id,
                               user=reset_request.user,
                               siteurl=get_application().cfg['site_url'].rstrip('/'))
        send_email(_('Your lost password request'), text, reset_request.user.email)
        return render_response('account/lost_password_sent.html')

    return render_response('account/lost_password.html', form=form.as_widget())