Fix: User login and server console logging functionality.

This commit is contained in:
2024-10-29 17:18:39 +00:00
parent f6e0eb7a02
commit 8cbc3ea973
5 changed files with 14 additions and 8 deletions

1
app.py
View File

@@ -71,6 +71,7 @@ app = Flask(__name__)
# AppConfig(app) # AppConfig(app)
app.config.from_object(app_config) # for db init with required keys app.config.from_object(app_config) # for db init with required keys
app.app_config = app_config
# app.config["config"] = app_config() # app.config["config"] = app_config()
# logging # logging

View File

@@ -20,6 +20,8 @@ load_dotenv(find_dotenv())
# CLASSES # CLASSES
class Config: class Config:
is_development = False
is_production = False
# Miscellaneous # Miscellaneous
DEBUG = False # av.input_bool(os.getenv('DEBUG'), 'DEBUG', 'Config') DEBUG = False # av.input_bool(os.getenv('DEBUG'), 'DEBUG', 'Config')
TESTING = False TESTING = False
@@ -68,11 +70,13 @@ class Config:
RECAPTCHA_PRIVATE_KEY = os.getenv('RECAPTCHA_PRIVATE_KEY') RECAPTCHA_PRIVATE_KEY = os.getenv('RECAPTCHA_PRIVATE_KEY')
class DevelopmentConfig(Config): class DevelopmentConfig(Config):
is_development = True
DEBUG = True DEBUG = True
MAIL_DEBUG = True MAIL_DEBUG = True
# Add development-specific configuration variables # Add development-specific configuration variables
class ProductionConfig(Config): class ProductionConfig(Config):
is_production = True
# Add production-specific configuration variables # Add production-specific configuration variables
pass pass

View File

@@ -36,5 +36,7 @@ class Helper_App(BaseModel):
@staticmethod @staticmethod
def console_log(message): def console_log(message):
if current_app.config["DEBUG"]: if current_app.app_config.is_development:
print(message) print(message)
elif current_app.app_config.is_production:
current_app.logger.info(message)

View File

@@ -92,13 +92,11 @@ BEGIN
IF ISNULL(a_id_user) THEN IF ISNULL(a_id_user) THEN
INSERT INTO tmp_Msg_Error ( INSERT INTO tmp_Msg_Error (
guid,
id_type, id_type,
code, code,
msg msg
) )
VALUES ( VALUES (
v_guid,
v_id_type_error_bad_data, v_id_type_error_bad_data,
v_code_error_bad_data, v_code_error_bad_data,
CONCAT('User ID required for authorisation.') CONCAT('User ID required for authorisation.')
@@ -479,9 +477,9 @@ END //
DELIMITER ;; DELIMITER ;;
/*
CALL p_get_many_user ( CALL p_get_many_user (NULL, 'google-oauth2|109567376920138999933', False, False, False, NULL, 'google-oauth2|109567376920138999933', 0);
/*
NULL # a_id_user NULL # a_id_user
, 'auth0|6582b95c895d09a70ba10fef' # a_id_user_auth0 , 'auth0|6582b95c895d09a70ba10fef' # a_id_user_auth0
, 0 # a_get_all_user , 0 # a_get_all_user
@@ -489,9 +487,10 @@ CALL p_get_many_user (
, 0 # a_get_first_user_only , 0 # a_get_first_user_only
, NULL # a_ids_user , NULL # a_ids_user
, 'auth0|6582b95c895d09a70ba10fef' # a_ids_user_auth0 , 'auth0|6582b95c895d09a70ba10fef' # a_ids_user_auth0
, 1 -- a_debug , 0 -- a_debug
); );*/
/*
select * FROM partsltd_prod.Shop_Calc_User_Temp; select * FROM partsltd_prod.Shop_Calc_User_Temp;
delete FROM partsltd_prod.Shop_Calc_User_Temp; delete FROM partsltd_prod.Shop_Calc_User_Temp;