Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_:warning: Potential issue_ #34

Open
yjn279 opened this issue Nov 16, 2024 · 0 comments
Open

_:warning: Potential issue_ #34

yjn279 opened this issue Nov 16, 2024 · 0 comments

Comments

@yjn279
Copy link
Contributor

yjn279 commented Nov 16, 2024

          _:warning: Potential issue_

プロジェクト削除の権限チェックを追加することを推奨します

現在の実装ではユーザーの認証のみを確認していますが、そのユーザーが特定のプロジェクトを削除する権限を持っているかどうかの確認が必要です。

以下のような権限チェックの追加を提案します:

 export async function deleteProjectAction(projectId: string) {
   try {
     const userId = await getSessionUserId();
     if (!userId) {
       return { success: false, error: "ユーザーが認証されていません。" };
     }
+    
+    // プロジェクトの所有者またはAdmin権限を持つユーザーかどうかを確認
+    const projectUser = await prisma.projectUser.findFirst({
+      where: {
+        projectId: projectId,
+        userId: userId,
+        role: 'ADMIN'
+      },
+    });
+    
+    if (!projectUser) {
+      return { success: false, error: "プロジェクトを削除する権限がありません。" };
+    }

Committable suggestion skipped: line range outside the PR's diff.

Originally posted by @coderabbitai[bot] in #33 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant