Skip to content

Commit

Permalink
[WEB-2778] chore: private project join restriction (#6082)
Browse files Browse the repository at this point in the history
* chore: private project join restriction

* chore: update project not found container layout

* chore: restrict other users to join private project

* chore: add check condition using enum

---------

Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
  • Loading branch information
NarayanBavisetti and aaryan610 authored Nov 22, 2024
1 parent b72d180 commit 6ef6282
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions apiserver/plane/app/views/project/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def list(self, request, slug):
def retrieve(self, request, slug, pk):
project = (
self.get_queryset()
.filter(
project_projectmember__member=self.request.user,
project_projectmember__is_active=True,
)
.filter(archived_at__isnull=True)
.filter(pk=pk)
.annotate(
Expand Down
6 changes: 6 additions & 0 deletions apiserver/plane/app/views/project/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ def create(self, request, slug):
member=request.user, workspace__slug=slug, is_active=True
)

if workspace_member.role != ROLE.ADMIN:
return Response(
{"error": "You do not have permission to join the project"},
status=status.HTTP_403_FORBIDDEN,
)

workspace_role = workspace_member.role
workspace = workspace_member.workspace

Expand Down
2 changes: 1 addition & 1 deletion web/core/layouts/auth-layout/project-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
// check if the project info is not found.
if (!loader && !projectExists && projectId && !!hasPermissionToCurrentProject === false)
return (
<div className="container grid h-screen place-items-center bg-custom-background-100">
<div className="grid h-screen place-items-center bg-custom-background-100">
<EmptyState
title="No such project exists"
description="Try creating a new project"
Expand Down

0 comments on commit 6ef6282

Please sign in to comment.