Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error #604

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -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')
4 changes: 2 additions & 2 deletions app/utils.py
Original file line number Diff line number Diff line change
@@ -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]: