Skip to content

Commit

Permalink
[user_accounts] Prevent crash when one user has 0 site/project affili…
Browse files Browse the repository at this point in the history
…ations (aces#8139)

Although this use case should never happen as it is prevented by rules in the edit_user logic, a couple bugs have let it happen in the past and the entire module becomes inaccessible. This makes the module load and displays a message in the user row informing the editor that the user does not currently have any sites and projects.

The only way to test this would be to manually delete all site associations directly in the DB user_psc_rel OR all project associations user_project_rel

Note that the module crashes even if the user not having any sites or projects is not the editor nor the editee... any user can cause this issue.
  • Loading branch information
ridz1208 authored and cmadjar committed Aug 10, 2022
1 parent 6c5718b commit 4d1e6c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/user_accounts/jsx/userAccountsIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class UserAccountsIndex extends Component {
.join(', ')}
</td>
);
if (cell.length === 0) {
result = (
<td>This user has no site affiliations</td>
);
}
break;
case 'Project':
// If user has multiple projects, join array of sites into string
Expand All @@ -86,6 +91,11 @@ class UserAccountsIndex extends Component {
).join(', ')}
</td>
);
if (cell.length === 0) {
result = (
<td>This user has no project affiliations</td>
);
}
break;
case 'Username':
url = loris.BaseURL + '/user_accounts/edit_user/' + row.Username;
Expand Down

0 comments on commit 4d1e6c1

Please # to comment.