Skip to content

Commit

Permalink
Merge pull request #18400 from mvdbeek/fix_get_accessible_job_without…
Browse files Browse the repository at this point in the history
…_session

[24.0] Fix ``get_accessible_job`` if called without session
  • Loading branch information
mvdbeek authored Jun 17, 2024
2 parents cedc325 + 5e6afdd commit 86b6eba
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ def update_job_lock(self, job_lock: JobLock):
)
return self.job_lock()

def get_accessible_job(self, trans, decoded_job_id) -> Job:
def get_accessible_job(self, trans: ProvidesUserContext, decoded_job_id) -> Job:
job = trans.sa_session.get(Job, decoded_job_id)
if job is None:
raise ObjectNotFound()
belongs_to_user = (
(job.user_id == trans.user.id)
if job.user_id and trans.user
else (job.session_id == trans.get_galaxy_session().id)
)
belongs_to_user = False
if trans.user:
belongs_to_user = job.user_id == trans.user.id
elif trans.galaxy_session:
belongs_to_user = job.session_id == trans.galaxy_session.id
if not trans.user_is_admin and not belongs_to_user:
# Check access granted via output datasets.
if not job.output_datasets:
Expand Down

0 comments on commit 86b6eba

Please sign in to comment.