From 4d1e6c1b584a9a1831bb058cb71e66120692af02 Mon Sep 17 00:00:00 2001 From: Rida Abou-Haidar Date: Thu, 14 Jul 2022 15:10:50 -0400 Subject: [PATCH] [user_accounts] Prevent crash when one user has 0 site/project affiliations (#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. --- modules/user_accounts/jsx/userAccountsIndex.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/user_accounts/jsx/userAccountsIndex.js b/modules/user_accounts/jsx/userAccountsIndex.js index 7f2543d8594..979a6201f16 100644 --- a/modules/user_accounts/jsx/userAccountsIndex.js +++ b/modules/user_accounts/jsx/userAccountsIndex.js @@ -77,6 +77,11 @@ class UserAccountsIndex extends Component { .join(', ')} ); + if (cell.length === 0) { + result = ( + This user has no site affiliations + ); + } break; case 'Project': // If user has multiple projects, join array of sites into string @@ -86,6 +91,11 @@ class UserAccountsIndex extends Component { ).join(', ')} ); + if (cell.length === 0) { + result = ( + This user has no project affiliations + ); + } break; case 'Username': url = loris.BaseURL + '/user_accounts/edit_user/' + row.Username;