Skip to content

Commit

Permalink
Fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Dec 13, 2024
1 parent 9040dd7 commit 2613159
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,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"]:
Expand Down Expand Up @@ -496,7 +496,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 = []
Expand Down Expand Up @@ -766,7 +766,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 = []
Expand Down Expand Up @@ -1120,7 +1120,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:
Expand Down Expand Up @@ -1175,7 +1175,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')
Expand All @@ -1193,7 +1193,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:
Expand All @@ -1212,7 +1212,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')
Expand Down
4 changes: 2 additions & 2 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 2613159

Please sign in to comment.