Add in authentication via Flask-Login, still need to modify http functions so they are linked to a user
This commit is contained in:
17
db.py
17
db.py
@@ -83,4 +83,19 @@ class DataBase():
|
||||
FROM http_function_invocations
|
||||
WHERE http_function_id=%s
|
||||
ORDER BY invocation_time DESC""", [http_function_id])
|
||||
return http_function_invocations
|
||||
return http_function_invocations
|
||||
|
||||
def get_user(self, user_id):
|
||||
user = self.execute(
|
||||
'SELECT id, username, password_hash, created_at FROM users WHERE id=%s', [int(user_id)], one=True)
|
||||
return user
|
||||
|
||||
def get_user_by_username(self, username):
|
||||
user = self.execute(
|
||||
'SELECT id, username, password_hash, created_at FROM users WHERE username=%s', [username], one=True)
|
||||
return user
|
||||
|
||||
def create_new_user(self, username, password_hash):
|
||||
new_user = self.execute(
|
||||
'INSERT INTO users (username, password_hash) VALUES (%s, %s) RETURNING id, username, password_hash, created_at', [username, password_hash], commit=True)
|
||||
return new_user
|
||||
Reference in New Issue
Block a user