Skip to content

fix: resolve user role inheritance when adding user to project#3572

Open
aashir-ali wants to merge 2 commits into
Leantime:masterfrom
devmechanix:fix/user-role-inheritance
Open

fix: resolve user role inheritance when adding user to project#3572
aashir-ali wants to merge 2 commits into
Leantime:masterfrom
devmechanix:fix/user-role-inheritance

Conversation

@aashir-ali

Copy link
Copy Markdown

I have updated the code for the to fix the "Inherit" issue

Copilot AI review requested due to automatic review settings July 1, 2026 08:10
@aashir-ali aashir-ali requested a review from a team as a code owner July 1, 2026 08:10
@aashir-ali aashir-ali requested review from marcelfolaron and removed request for a team July 1, 2026 08:10
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses incorrect “Inherit” project-role handling when assigning users to a project by preventing “inherit” selections from being persisted as a numeric role value and by treating stored 0 as “no explicit project role” during role resolution.

Changes:

  • Adjusts project-role lookup to treat projectRole = 0 as “no explicit role” (inherit global role).
  • Updates project user relation editing to recognize the "inherit" UI value and avoid casting it into an integer role.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
app/Domain/Projects/Services/Projects.php Treats projectRole values that cast to 0 as “no explicit role” when resolving a user’s project role.
app/Domain/Projects/Repositories/Projects.php Prevents "inherit" from being cast and persisted as an integer role when updating project-user relations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1052 to +1054
if (is_array($project)) {
if (isset($project[0]['projectRole']) && $project[0]['projectRole'] != '' && (int) $project[0]['projectRole'] !== 0) {
return (string) $project[0]['projectRole'];
Comment on lines +794 to 797
$roleValue = $values['projectRoles']['userProjectRole-'.$userId] ?? null;
if ($roleValue !== null && $roleValue !== 'inherit' && $roleValue !== '40' && $roleValue !== '50') {
$projectRole = (int) $roleValue;
}
Copilot AI review requested due to automatic review settings July 1, 2026 08:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines 792 to 796
$projectRole = null;
if (isset($values['projectRoles']['userProjectRole-'.$userId]) && $values['projectRoles']['userProjectRole-'.$userId] != '40' && $values['projectRoles']['userProjectRole-'.$userId] != '50') {
$projectRole = (int) $values['projectRoles']['userProjectRole-'.$userId];
$roleValue = $values['projectRoles']['userProjectRole-'.$userId] ?? null;
if ($roleValue !== null && $roleValue !== 'inherit' && $roleValue !== '40' && $roleValue !== '50') {
$projectRole = (int) $roleValue;
}
Comment on lines +1055 to 1063
if (is_array($project)) {
if (isset($project[0]['projectRole']) && $project[0]['projectRole'] != '' && (int) $project[0]['projectRole'] !== 0) {
return (string) $project[0]['projectRole'];
} else {
return '';
}
} else {
return '';
}
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

Successfully merging this pull request may close these issues.

4 participants