Skip to content

Commit b2d2162

Browse files
author
Bernat Romagosa
committed
make sure project pages can only be seen if own project, or shared/public
1 parent 4a407de commit b2d2162

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

site.lua

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ app:match('project', '/project', capture_errors(function (self)
232232
self.params.projectname
233233
)
234234
assert_project_exists(self)
235+
assert_can_view_project(self)
235236

236237
-- check whether this is a remix of another project
237238
local remix =

validation.lua

+9
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ assert_project_exists = function (self, project)
294294
return proj
295295
end
296296

297+
assert_can_view_project = function (self, project)
298+
local proj = self.project or project
299+
if (not proj.ispublished and not proj.ispublic
300+
and not users_match(self) and not self.current_user:isadmin())
301+
then
302+
yield_error(err.nonexistent_project)
303+
end
304+
end
305+
297306
-- Tokens
298307

299308
check_token = function (self, token, purpose, on_success)

0 commit comments

Comments
 (0)