Skip to content

Fix module mentor deadline permissions - #5722

Closed
saksham-rathore wants to merge 1 commit into
OWASP:mainfrom
saksham-rathore:fix/module-mentor-deadline-permissions
Closed

saksham-rathore wants to merge 1 commit into
OWASP:mainfrom
saksham-rathore:fix/module-mentor-deadline-permissions

Conversation

@saksham-rathore

Copy link
Copy Markdown

Proposed change

Resolves #5721

Enforce module-mentor-only authorization for task deadline mutations.

Backend

  • set_task_deadline now requires module.has_mentor(user); removed the program-admin and mentee
    (mentee_can_manage_deadlines / issue-assignee) authorization paths and the unused
    NOT_MENTEE_ASSIGNEE_SET_DEADLINE_MSG constant.
  • clear_task_deadline already enforced mentor-only access and stays unchanged.
  • Added ModuleNode.userIsModuleMentor, resolved from Module.has_mentor(request.user), so clients
    can distinguish module mentors from program admins (userRole reports admins first).
  • Deadline validation (issue existence, assignees, normalization, module date boundaries) is untouched.

Frontend (Mentorship Portal)

  • Issue view query fetches userIsModuleMentor.
  • Issue details page: canEditDeadline = isModuleMentor && assignees.length > 0; deadline controls no
    longer depend on userRole, session login, or menteeCanManageDeadlines.
  • Clearing a deadline is gated on module-mentor status.

Tests

  • Backend: program admin without mentor role denied for set and clear; mentee denied even when
    mentee_can_manage_deadlines is enabled and the issue is assigned; denied attempts perform no task
    updates; userIsModuleMentor resolver coverage.
  • Frontend: mentee deadline controls always read-only, non-mentor admin disabled, mentor (including
    admin-mentor) enabled, mentor set-deadline path covered.

Checklist

[ ] Required: I followed the contributing workflow
[ ] Required: I verified that my code works as intended and resolves the issue as described
[ ] Required: I ran all required checks and tests locally; all warnings addressed and failures resolved

@github-actions

Copy link
Copy Markdown

Contribution validation failed:

  • issue_assignee: The linked issue must be assigned to the PR author before this PR can be merged.

  • commit_signature: One or more commits are not signed.

  • commit_sign_off: One or more commits are missing or have an invalid Signed-off-by trailer.

@github-actions github-actions Bot closed this Oct 20, 2026
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: OWASP/Nest/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6f5195db-ab76-41b9-a2a7-d78dbe4158a5
📥 Commits

Reviewing files that changed from the base of the PR and between 2ab940d and f3f8d1e.

⛔ Files ignored due to path filters: 2
  • frontend/src/types/__generated__/graphql.ts is excluded by !**/__generated__/**
  • frontend/src/types/__generated__/issueQueries.generated.ts is excluded by !**/*.generated.*, !**/__generated__/**
📒 Files selected for processing: 7
  • backend/src/apps/mentorship/api/internal/mutations/module.py
  • backend/src/apps/mentorship/api/internal/nodes/module.py
  • backend/tests/unit/apps/mentorship/api/internal/mutations/module_mutation_test.py
  • backend/tests/unit/apps/mentorship/api/internal/nodes/api_internal_module_test.py
  • frontend/__tests__/unit/pages/ModuleIssueDetailsPage.test.tsx
  • frontend/src/app/my/mentorship/programs/[programKey]/modules/[moduleKey]/issues/[issueId]/page.tsx
  • frontend/src/server/queries/issueQueries.ts
+-------------------------------------------------+
| If you only knew now what you didn't know then. |
+-------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce Module-Mentor Permissions When Setting Task Deadlines

1 participant