diff --git a/cps/__init__.py b/cps/__init__.py index 9bf03761..269e4aca 100644 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -112,16 +112,18 @@ def create_app(): cli_param.init() - ub.init_db(cli_param.settings_path, cli_param.user_credentials) - + ub.init_db(cli_param.settings_path) # pylint: disable=no-member encrypt_key, error = config_sql.get_encryption_key(os.path.dirname(cli_param.settings_path)) config_sql.load_configuration(ub.session, encrypt_key) config.init_config(ub.session, encrypt_key, cli_param) + if error: log.error(error) + ub.password_change(cli_param.user_credentials) + if not limiter: log.info('*** "flask-limiter" is needed for calibre-web to run. ' 'Please install it using pip: "pip install flask-limiter" ***') diff --git a/cps/ub.py b/cps/ub.py index c76fc0e5..56c2e9e8 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -818,7 +818,7 @@ def init_db_thread(): return Session() -def init_db(app_db_path, user_credentials=None): +def init_db(app_db_path): # Open session for database connection global session global app_DB_path @@ -839,6 +839,7 @@ def init_db(app_db_path, user_credentials=None): create_admin_user(session) create_anonymous_user(session) +def password_change(user_credentials=None): if user_credentials: username, password = user_credentials.split(':', 1) user = session.query(User).filter(func.lower(User.name) == username.lower()).first()