Skip to content

Commit

Permalink
more checks on current user (#547)
Browse files Browse the repository at this point in the history
This PR checks for user or token.
  • Loading branch information
mcoughlin authored Apr 26, 2024
1 parent 69194d2 commit 49e8851
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extensions/skyportal/skyportal/handlers/api/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def post(self):

with self.Session() as session:
obj = session.scalars(
Obj.select(self.current_user).where(Obj.id == obj_id)
Obj.select(session.user_or_token).where(Obj.id == obj_id)
).first()
if obj is None:
return self.error(
Expand All @@ -508,7 +508,7 @@ def post(self):

group_ids = [g.id for g in self.current_user.accessible_groups]
groups = session.scalars(
Group.select(self.current_user).where(Group.id.in_(group_ids))
Group.select(session.user_or_token).where(Group.id.in_(group_ids))
).all()

if {g.id for g in groups} != set(group_ids):
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def post(self):
photometry["stream_ids"] = df_photometry["stream_ids"].tolist()

if len(photometry.get("mag", ())) > 0:
add_external_photometry(photometry, self.current_user)
add_external_photometry(photometry, self.associated_user_object)

finally:
# always attempt deleting the temporary token
Expand Down

0 comments on commit 49e8851

Please sign in to comment.