Skip to content

Commit

Permalink
make sure project pages can only be seen if own project, or shared/pu…
Browse files Browse the repository at this point in the history
…blic
  • Loading branch information
bromagosa committed Mar 20, 2024
1 parent 4a407de commit b2d2162
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions site.lua
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ app:match('project', '/project', capture_errors(function (self)
self.params.projectname
)
assert_project_exists(self)
assert_can_view_project(self)

-- check whether this is a remix of another project
local remix =
Expand Down
9 changes: 9 additions & 0 deletions validation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ assert_project_exists = function (self, project)
return proj
end

assert_can_view_project = function (self, project)
local proj = self.project or project
if (not proj.ispublished and not proj.ispublic
and not users_match(self) and not self.current_user:isadmin())
then
yield_error(err.nonexistent_project)
end
end

-- Tokens

check_token = function (self, token, purpose, on_success)
Expand Down

0 comments on commit b2d2162

Please sign in to comment.