@post('/account/reset')
def request_reset():
    """
    Password reset form POST endpoint.
    """
    email = request.forms.get('email')
    user = local.model.get_user(username=email)
    if user is None:
        # Redirect back to form page
        return redirect_with_query('/account/reset', {
            'error': "User with email %s not found." % email
        })

    # Generate reset code
    reset_code = local.model.new_user_reset_code(user.user_id)

    # Send code
    hostname = request.get_header('X-Forwarded-Host') or request.get_header('Host')
    user_name = user.first_name or user.user_name
    local.emailer.send_email(
        subject="CodaLab password reset link",
        body=template('password_reset_body', user=user_name, current_site=hostname, code=reset_code),
        recipient=email,
    )

    # Redirect to success page
    return redirect('/account/reset/sent')
dataset/ETHPy150Open codalab/codalab-cli/codalab/rest/account.py/request_reset/original