Esempio n. 1
0
def login():
    if API.get_config_value("webui", "nolocalauth") \
       and bottle.request.environ.get("REMOTE_ADDR", "0") in ("127.0.0.1", "localhost"):
        set_session(request, "local")
        return bottle.redirect("/")
    else:
        return render_to_response("login.html", proc=[pre_processor])
Esempio n. 2
0
def login_post():
    user = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")

    remote_addr = bottle.request.environ.get("REMOTE_ADDR", "0")

    info = API.check_auth(user, password)

    if info:
        API.pyload.log.debug(_("WebUI login from IP address: %s") % remote_addr)
    else:
        API.pyload.log.warning(_("Failed WebUI login from IP address: %s") % remote_addr)
        return render_to_response("login.html", {"errors": True}, [pre_processor])

    set_session(info)
    return bottle.redirect("/")
Esempio n. 3
0
def login():
    bottle.response.headers.replace("Content-type", "application/json")
    bottle.response.headers.append("Cache-Control", "no-cache, must-revalidate")

    user = bottle.request.forms.get("username")
    password = bottle.request.forms.get("password")

    remote_addr = bottle.request.environ.get("REMOTE_ADDR", "0")

    info = API.check_auth(user, password)

    if info:
        API.pyload.log.debug(_("API login from IP address: %s") % remote_addr)
    else:
        API.pyload.log.warning(_("Failed API login from IP address: %s") % remote_addr)
        return json_dumps(False)

    s = set_session(request, info)

    # get the session id by dirty way, documentations seems wrong
    try:
        sid = s._headers['cookie_out'].split("=")[1].split(";")[0]
        return json_dumps(sid)
    except Exception:
        return json_dumps(True)