app.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:aniping 作者: kuruoujou 项目源码 文件源码
def login():
    """Login POST handler.

    Only runs when ``/login`` is hit with a POST method. There is no GET method
    equivilent, as it is handled by the navigation template. Sets the status
    code to ``401`` on login failure.

    Returns:
        JSON formatted output describing success or failure.
    """
    log.debug("Entering login, attempting to authenticate user.")
    username = request.form['signin_username']
    password = request.form['signin_password']
    log.debug("Username: {0}".format(username))
    if fe.check_auth(username, password):
        log.debug("User authenticated. Trying to set session.")
        session_id = fe.set_login_id()
        session['logged_in'] = session_id
        log.debug("Session ID: {0}, returning to user".format(session_id))
        return jsonify({ "login": "success" })
    log.debug("Username or password not recognized, sending 401.")
    response.status = 401
    return jsonify({ "login": "failed" })
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号