aboutsummaryrefslogtreecommitdiff
path: root/api/hierarchy.py
diff options
context:
space:
mode:
Diffstat (limited to 'api/hierarchy.py')
-rw-r--r--api/hierarchy.py70
1 files changed, 35 insertions, 35 deletions
diff --git a/api/hierarchy.py b/api/hierarchy.py
index 247ee9e..7b60f8d 100644
--- a/api/hierarchy.py
+++ b/api/hierarchy.py
@@ -9,13 +9,13 @@ ranks = ["none", "user", "moderator", "admin", "bot"]
def util_two_id(type="user"):
'''
- type?: "user" | "game"
- ! only used internally !
- func(token_id?: str, explicit_id?: str)
+ type?: "user" | "game"
+ ! only used internally !
+ func(token_id?: str, explicit_id?: str)
- This decorator doesn't check for hierarchy constraints, but does
- make sure that token_id or explicit_id are valid user_id's
- '''
+ This decorator doesn't check for hierarchy constraints, but does
+ make sure that token_id or explicit_id are valid user_id's
+ '''
def decorator(func):
def wrapper():
token_id = None
@@ -29,7 +29,7 @@ def util_two_id(type="user"):
# if there's an explicit_id, validate it using `type`
if explicit_id and \
- not valid.validate(explicit_id, type):
+ not valid.validate(explicit_id, type):
explicit_id = None
return func(token_id, explicit_id)
@@ -42,12 +42,12 @@ def util_two_id(type="user"):
def two_person(func):
'''
- endpoint should have two parameters:
- endpoint(user_1_id: str, user_2_id: str)
+ endpoint should have two parameters:
+ endpoint(user_1_id: str, user_2_id: str)
- no authentication, just runs endpoint() if both token_id and
- explicit_id are present from @util_two_id.
- '''
+ no authentication, just runs endpoint() if both token_id and
+ explicit_id are present from @util_two_id.
+ '''
@util_two_id("user")
def wrapper(token_id, explicit_id):
if not all_def([token_id, explicit_id]):
@@ -61,13 +61,13 @@ def two_person(func):
def one_person(func):
'''
- endpoint should have two parameters:
- endpoint(user_id: str, viewer?: str)
+ endpoint should have two parameters:
+ endpoint(user_id: str, viewer?: str)
- uses json data id with token_login id as fallback
- doesn't check for authentication
- expects that func takes these arguments: (user_id, viewer?)
- '''
+ uses json data id with token_login id as fallback
+ doesn't check for authentication
+ expects that func takes these arguments: (user_id, viewer?)
+ '''
@util_two_id("user")
def wrapper(token_id, explicit_id):
if all_notdef([token_id, explicit_id]):
@@ -81,9 +81,9 @@ def one_person(func):
def game_id_with_viewer(func):
'''
- endpoint should have two parameters:
- endpoint(game_id: str, viewer?: str)
- '''
+ endpoint should have two parameters:
+ endpoint(game_id: str, viewer?: str)
+ '''
@util_two_id("game")
def wrapper(token_id, game_id):
if all_notdef([token_id, game_id]):
@@ -97,14 +97,14 @@ def game_id_with_viewer(func):
def auth_required(level):
'''
- level = "none" | "user" | "moderator" | "admin" | "bot"
- endpoint should have one parameter for the user_id of the request author:
- endpoint(user_id: str) # `user_id` can only be `None` when `level == "none"`
-
- @auth_required function decorator (use after @flask.Blueprint.route() decorator)
- This decorator only runs endpoint() if token_id from
- @util_two_id is not None and passes hierarchy constraints
- '''
+ level = "none" | "user" | "moderator" | "admin" | "bot"
+ endpoint should have one parameter for the user_id of the request author:
+ endpoint(user_id: str) # `user_id` can only be `None` when `level == "none"`
+
+ @auth_required function decorator (use after @flask.Blueprint.route() decorator)
+ This decorator only runs endpoint() if token_id from
+ @util_two_id is not None and passes hierarchy constraints
+ '''
def decorator(func):
@util_two_id("user")
def wrapper(token_id, explicit_id):
@@ -132,13 +132,13 @@ def auth_required(level):
def io_auth_required(level):
'''
- level = "none" | "user" | "moderator" | "admin" | "bot"
- endpoint should have two parameters:
- endpoint(data: socket.io.data, user_id: str) # `user_id` can only be `None` when `level == "none"`
+ level = "none" | "user" | "moderator" | "admin" | "bot"
+ endpoint should have two parameters:
+ endpoint(data: socket.io.data, user_id: str) # `user_id` can only be `None` when `level == "none"`
- uses the @auth_required decorator, but is only for use with
- @io.on decorators
- '''
+ uses the @auth_required decorator, but is only for use with
+ @io.on decorators
+ '''
def decorator(func):
# data is the original @io.on data
def wrapper(data={}):