Add option to make http functions private (Require authentication, currently just redirects to login page; Should look into cookie + JWT + api key)
This commit is contained in:
18
db.py
18
db.py
@@ -49,21 +49,27 @@ class DataBase():
|
||||
|
||||
def get_http_functions_for_user(self, user_id):
|
||||
http_functions = self.execute(
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info FROM http_functions WHERE user_id=%s ORDER by id DESC', [user_id])
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public FROM http_functions WHERE user_id=%s ORDER by id DESC', [user_id])
|
||||
return http_functions
|
||||
|
||||
def get_http_function(self, user_id, name):
|
||||
http_function = self.execute(
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info FROM http_functions WHERE user_id=%s AND NAME=%s', [user_id, name], one=True)
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public FROM http_functions WHERE user_id=%s AND NAME=%s', [user_id, name], one=True)
|
||||
return http_function
|
||||
|
||||
def create_new_http_function(self, user_id, name, script_content, environment_info):
|
||||
def create_new_http_function(self, user_id, name, script_content, environment_info, is_public=False):
|
||||
self.execute(
|
||||
'INSERT INTO http_functions (user_id, NAME, script_content, environment_info) VALUES (%s, %s, %s, %s)', [user_id, name, script_content, environment_info], commit=True)
|
||||
'INSERT INTO http_functions (user_id, NAME, script_content, environment_info, is_public) VALUES (%s, %s, %s, %s, %s)',
|
||||
[user_id, name, script_content, environment_info, is_public],
|
||||
commit=True
|
||||
)
|
||||
|
||||
def edit_http_function(self, user_id, name, script_content, environment_info):
|
||||
def edit_http_function(self, user_id, name, script_content, environment_info, is_public):
|
||||
self.execute(
|
||||
'UPDATE http_functions SET script_content=%s, environment_info=%s WHERE user_id=%s AND NAME=%s', [script_content, environment_info, user_id, name], commit=True)
|
||||
'UPDATE http_functions SET script_content=%s, environment_info=%s, is_public=%s WHERE user_id=%s AND NAME=%s',
|
||||
[script_content, environment_info, is_public, user_id, name],
|
||||
commit=True
|
||||
)
|
||||
|
||||
def update_http_function_environment_info_and_invoked_count(self, user_id, name, environment_info):
|
||||
self.execute(
|
||||
|
||||
Reference in New Issue
Block a user