summaryrefslogtreecommitdiffstats
path: root/module/web/webinterface.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/web/webinterface.py')
-rw-r--r--module/web/webinterface.py57
1 files changed, 27 insertions, 30 deletions
diff --git a/module/web/webinterface.py b/module/web/webinterface.py
index 49e8e831c..be28fb2eb 100644
--- a/module/web/webinterface.py
+++ b/module/web/webinterface.py
@@ -19,7 +19,6 @@
import sys
import gettext
-import sqlite3
from os.path import join, abspath,dirname, exists
from os import makedirs
@@ -48,24 +47,34 @@ try:
except:
import xmlrpclib
- ssl = ""
-
from module.ConfigParser import ConfigParser
-
config = ConfigParser()
-
- if config.get("ssl", "activated"):
- ssl = "s"
-
- server_url = "http%s://%s:%s@%s:%s/" % (
- ssl,
- config.username,
- config.password,
- config.get("remote", "listenaddr"),
- config.get("remote", "port")
- )
-
- PYLOAD = xmlrpclib.ServerProxy(server_url, allow_none=True)
+
+ class wrap():
+ authed = False
+ proxy = None
+ def checkAuth(self, username, password):
+ server_url = "http%s://%s:%s@%s:%s/" % (
+ "s" if config.get("ssl", "activated") else "",
+ username,
+ password,
+ config.get("remote", "listenaddr"),
+ config.get("remote", "port")
+ )
+ proxy = xmlrpclib.ServerProxy(server_url, allow_none=True)
+ try:
+ info = proxy.checkAuth(username, password)
+ except:
+ self.authed = False
+ return {}
+ self.proxy = proxy
+ self.authed = False
+ return info
+
+ def __getattr__(self, attr):
+ return getattr(self.proxy, attr)
+
+ PYLOAD = wrap()
from module.JsEngine import JsEngine
@@ -77,18 +86,6 @@ LOG_ROOT = config.get('log', 'log_folder')
DEBUG = config.get("general","debug_mode")
bottle.debug(DEBUG)
-def setup_database():
- conn = sqlite3.connect('web.db')
- c = conn.cursor()
- c.execute(
- 'CREATE TABLE IF NOT EXISTS "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "name" TEXT NOT NULL, "email" TEXT DEFAULT "" NOT NULL, "password" TEXT NOT NULL, "role" INTEGER DEFAULT 0 NOT NULL, "permission" INTEGER DEFAULT 0 NOT NULL, "template" TEXT DEFAULT "default" NOT NULL)')
- c.close()
- conn.commit()
- conn.close()
-
-setup_database()
-
-
if not exists(join("tmp", "jinja_cache")):
makedirs(join("tmp", "jinja_cache"))
@@ -148,4 +145,4 @@ def run_fcgi(host="0.0.0.0", port="8000"):
if __name__ == "__main__":
- run(app=web, port=8001) \ No newline at end of file
+ run(app=web, port=8001)