|
@@ -10,6 +10,7 @@ import logging
|
|
|
import logging.handlers
|
|
|
import hashlib
|
|
|
import contextlib
|
|
|
+import toml
|
|
|
|
|
|
|
|
|
# We log what happens every time someone connects
|
|
@@ -250,15 +251,22 @@ def method_update():
|
|
|
|
|
|
# Checks if the user has the permissions to use the requested method
|
|
|
def auth(user_id, method, kind):
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-# with open(DIR + "/auth/" + kind + "/" + method) as f:
|
|
|
-# for line in f:
|
|
|
-# if int(line) == user_id:
|
|
|
-# return
|
|
|
-# raise AuthError()
|
|
|
+ user_type = ""
|
|
|
+ for file_name in ["150","Admin","Valhalla","Nirvana"]:
|
|
|
+ with open(DIR + "/auth/" + file_name) as f:
|
|
|
+ for line in f:
|
|
|
+ line = line.split()[0]
|
|
|
+ if int(line) == user_id:
|
|
|
+ user_type = file_name
|
|
|
+ break
|
|
|
+ if not user_type == "":
|
|
|
+ break
|
|
|
+ else:
|
|
|
+ raise AuthError()
|
|
|
+ auth_list = toml.load(DIR + "/auth/auth.toml")[user_type]["auth"]
|
|
|
+ if not method + " " + kind in auth_list:
|
|
|
+ raise AuthError()
|
|
|
+ return
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|