Implement token management and authentication features with logging
This commit is contained in:
@@ -2,6 +2,7 @@ from dotenv import load_dotenv
|
||||
import db
|
||||
import os
|
||||
import logging
|
||||
import api_security as auth
|
||||
|
||||
#Logging
|
||||
|
||||
@@ -32,13 +33,13 @@ db.connect(db_user, db_psswd, db_host, int(db_port), db_name)
|
||||
def new_table(name):
|
||||
cursor = db.connection.cursor()
|
||||
if name == "tokens":
|
||||
executed = "CREATE TABLE tokens (tokens VARCHAR(50) PRIMARY KEY, `time` VARCHAR(50), duration VARCHAR(50))"
|
||||
executed = "CREATE TABLE tokens (tokens VARCHAR(255) PRIMARY KEY, `time` VARCHAR(255), end_date VARCHAR(255))"
|
||||
cursor.execute(executed)
|
||||
db.connection.commit()
|
||||
logging.info("Table 'tokens' created")
|
||||
|
||||
if name == "luggage":
|
||||
executed = "CREATE TABLE luggage (clothes VARCHAR(50) PRIMARY KEY, `weight` DECIMAL(20,2), pieces INT(11))"
|
||||
executed = "CREATE TABLE luggage (clothes VARCHAR(50) PRIMARY KEY, weight DECIMAL(20,2), pieces INT(11))"
|
||||
cursor.execute(executed)
|
||||
db.connection.commit()
|
||||
logging.info("Table 'luggage' created")
|
||||
@@ -46,4 +47,5 @@ def new_table(name):
|
||||
|
||||
new_table("tokens")
|
||||
new_table("luggage")
|
||||
print(auth.admin_token())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user