Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions apps/api/plane/app/views/project/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,38 @@ class ProjectJoinEndpoint(BaseAPIView):
def post(self, request, slug, project_id, pk):
project_invite = ProjectMemberInvite.objects.get(pk=pk, project_id=project_id, workspace__slug=slug)

email = request.data.get("email", "")
token = request.data.get("token", "")

if email == "" or project_invite.email != email:
# Validate the token to verify the user received the invitation email
if not token or project_invite.token != token:
return Response(
{"error": "You do not have permission to join the project"},
status=status.HTTP_403_FORBIDDEN,
)

# Require an authenticated session — the accepting user must be the
# person who was invited. Without this check an attacker who knows the
# invitee email and obtains the token can hijack the project membership
# (GHSA-g36h-p63v-g9c7).
if not request.user.is_authenticated:
return Response(
{"error": "Authentication required to accept project invitation"},
status=status.HTTP_401_UNAUTHORIZED,
)
if request.user.email.lower() != project_invite.email.lower():
return Response(
{"error": "You do not have permission to accept this invitation"},
status=status.HTTP_403_FORBIDDEN,
)

if project_invite.responded_at is None:
project_invite.accepted = request.data.get("accepted", False)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
project_invite.responded_at = timezone.now()
project_invite.save()

if project_invite.accepted:
# Check if the user account exists
user = User.objects.filter(email=email).first()
user = User.objects.filter(email=project_invite.email).first()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

# Check if user is a part of workspace
workspace_member = WorkspaceMember.objects.filter(workspace__slug=slug, member=user).first()
Expand Down
Loading