summaryrefslogtreecommitdiffstats
path: root/module/web/pyload_app.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-08-13 17:40:10 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-08-13 17:40:10 +0200
commit941e3021000e59020f66419cc2156aee30972121 (patch)
tree49332fb148dd50c0ee78e4c20336c2848921bc1a /module/web/pyload_app.py
parentmerge (diff)
downloadpyload-941e3021000e59020f66419cc2156aee30972121.tar.xz
working login
Diffstat (limited to 'module/web/pyload_app.py')
-rw-r--r--module/web/pyload_app.py50
1 files changed, 17 insertions, 33 deletions
diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py
index ba74d7083..afb97b361 100644
--- a/module/web/pyload_app.py
+++ b/module/web/pyload_app.py
@@ -23,43 +23,27 @@ from bottle import route, static_file, request, response, redirect, HTTPError, e
from webinterface import PYLOAD, PROJECT_DIR, SETUP, env
-from utils import render_to_response, parse_permissions, parse_userdata, set_session
+from utils import render_to_response, login_required, set_session, get_user_api
-from module.Api import Output
##########
# Helper
##########
-
# TODO: useful but needs a rewrite, too
def pre_processor():
s = request.environ.get('beaker.session')
- user = parse_userdata(s)
- perms = parse_permissions(s)
- status = {}
- captcha = False
- update = False
- plugins = False
- if user["is_authenticated"]:
- status = PYLOAD.statusServer()
- info = PYLOAD.getInfoByPlugin("UpdateManager")
- captcha = PYLOAD.isInteractionWaiting(Output.Captcha)
-
- # check if update check is available
- if info:
- if info["pyload"] == "True": update = True
- if info["plugins"] == "True": plugins = True
+ api = get_user_api(s)
+ user = None
+ status = None
+ if api is not None:
+ user = api.user
+ status = api.statusServer()
return {"user": user,
- 'status': status,
- 'captcha': captcha,
- 'perms': perms,
- 'url': request.url,
- 'update': update,
- 'plugins': plugins}
-
+ 'server': status,
+ 'url': request.url }
def base(messages):
@@ -68,11 +52,11 @@ def base(messages):
@error(500)
def error500(error):
- print "An error occured while processing the request."
+ print "An error occurred while processing the request."
if error.traceback:
print error.traceback
- return base(["An error occured while processing the request.", error,
+ return base(["An error occurred while processing the request.", error,
error.traceback.replace("\n", "<br>") if error.traceback else "No Traceback"])
# TODO: not working
@@ -125,15 +109,14 @@ def nopermission():
@route("/login", method="POST")
def login_post():
- user = request.forms.get("username")
+ username = request.forms.get("username")
password = request.forms.get("password")
- info = PYLOAD.checkAuth(user, password)
-
- if not info:
+ user = PYLOAD.checkAuth(username, password)
+ if not user:
return render_to_response("login.html", {"errors": True}, [pre_processor])
- set_session(request, info)
+ set_session(request, user)
return redirect("/")
@@ -144,6 +127,7 @@ def logout():
return render_to_response("logout.html", proc=[pre_processor])
@route("/")
-def index():
+@login_required()
+def index(api):
return base(["It works!"])