From f0bfb8a13b6b488c561084a4a33acc9b75984b03 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 24 Jul 2013 17:42:43 +0200 Subject: improved login mechanism --- pyload/web/api_app.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'pyload/web/api_app.py') diff --git a/pyload/web/api_app.py b/pyload/web/api_app.py index 3ffc507aa..c88be0519 100644 --- a/pyload/web/api_app.py +++ b/pyload/web/api_app.py @@ -8,12 +8,13 @@ from traceback import format_exc, print_exc from bottle import route, request, response, HTTPError, parse_auth from utils import set_session, get_user_api -from webinterface import PYLOAD +from webinterface import PYLOAD, session from pyload.Api import ExceptionObject -from pyload.remote.json_converter import loads, dumps +from pyload.remote.json_converter import loads, dumps, BaseEncoder from pyload.utils import remove_chars + def add_header(r): r.headers.replace("Content-type", "application/json") r.headers.append("Cache-Control", "no-cache, must-revalidate") @@ -95,10 +96,13 @@ def login(): # get the session id by dirty way, documentations seems wrong try: sid = s._headers["cookie_out"].split("=")[1].split(";")[0] - return dumps(sid) + # reuse old session id except: - print "Could not get session" - return dumps(True) + sid = request.get_header(session.options['key']) + + result = BaseEncoder().default(user) + result["session"] = sid + return dumps(result) @route("/api/logout") -- cgit v1.2.3