From 6a6b47a43dcbab9323d27231bcca0986bc3ce138 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Fri, 13 Dec 2024 12:15:57 +0100 Subject: [PATCH] Fix error --- app/__init__.py | 14 +++++++------- app/utils.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index cecd1598..37f38204 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -254,7 +254,7 @@ def home(): # Force to get the user credentials to cache them scheduler.add_job(func=utils.get_cache_creds, trigger='date', run_date=datetime.datetime.now(), - misfire_grace_time=20, args=[cred, get_cred_id()], id='get_cache_creds') + misfire_grace_time=20, args=[cred, session['userid'], get_cred_id()], id='get_cache_creds') # if there are any next url, redirect to it if "next" in session and session["next"]: @@ -502,7 +502,7 @@ def showinfrastructures(): app.logger.exception("Error getting vm info: %s" % ex) radl_json = [] try: - creds = utils.get_cache_creds(cred, get_cred_id()) + creds = utils.get_cache_creds(cred, session['userid'], get_cred_id()) except Exception as ex: app.logger.exception("Error getting user credentials: %s" % ex) creds = [] @@ -772,7 +772,7 @@ def configure(): app.logger.debug("Template: " + json.dumps(toscaInfo[selected_tosca])) try: - creds = utils.get_cache_creds(cred, get_cred_id(), 1) + creds = utils.get_cache_creds(cred, session['userid'], get_cred_id(), 1) except Exception as ex: flash("Error getting user credentials: %s" % ex, "error") creds = [] @@ -1126,7 +1126,7 @@ def manage_creds(): creds = {} try: - creds = utils.get_cache_creds(cred, get_cred_id()) + creds = utils.get_cache_creds(cred, session['userid'], get_cred_id()) # Get the project_id in case it has changed utils.get_project_ids(creds) except Exception as e: @@ -1181,7 +1181,7 @@ def write_creds(): # Get project_id to save it to de DB utils.get_project_ids([creds]) # delete cached credentials - utils.clear_cache_creds(get_cred_id()) + utils.clear_cache_creds(session['userid']) cred.write_creds(creds["id"], get_cred_id(), creds, cred_id in [None, '']) if val_res == 0: flash("Credentials successfully written!", 'success') @@ -1199,7 +1199,7 @@ def delete_creds(): cred_id = request.args.get('cred_id', "") try: # delete cached credentials - utils.clear_cache_creds(get_cred_id()) + utils.clear_cache_creds(session['userid']) cred.delete_cred(cred_id, get_cred_id()) flash("Credentials successfully deleted!", 'success') except Exception as ex: @@ -1218,7 +1218,7 @@ def enable_creds(): if val_res == 2: flash(val_msg, 'warning') # delete cached credentials - utils.clear_cache_creds(get_cred_id()) + utils.clear_cache_creds(session['userid']) cred.enable_cred(cred_id, get_cred_id(), enable) except Exception as ex: flash("Error updating credentials %s!" % ex, 'error') diff --git a/app/utils.py b/app/utils.py index bb202afa..75622f52 100644 --- a/app/utils.py +++ b/app/utils.py @@ -985,10 +985,10 @@ def merge_templates(template, new_template): return template -def get_cache_creds(cred, userid, enabled=None): +def get_cache_creds(cred, userid, creduserid, enabled=None): global CREDS_CACHE if userid not in CREDS_CACHE: - CREDS_CACHE[userid] = cred.get_creds(userid) + CREDS_CACHE[userid] = cred.get_creds(creduserid) res = [] for cred in CREDS_CACHE[userid]: