Skip to content

VACMS-00000: fix password issue #20824

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

Merged
merged 15 commits into from
Mar 12, 2025
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docroot/modules/custom/va_gov_db/va_gov_db.install
Original file line number Diff line number Diff line change
Expand Up @@ -1183,3 +1183,42 @@ function va_gov_db_update_10001(): string {
];
return _va_gov_db_uninstall_modules($uninstall_modules);
}

/**
* NULL out passwords for everyone except service accounts.
*/
function va_gov_db_update_10002() {
// Get user storage object.
$user_storage = \Drupal::entityTypeManager()->getStorage('user');

// Get all users.
$ids = $user_storage->getQuery()
->condition('status', 1)
->accessCheck(FALSE)
->execute();

$service_accounts = [
'3665',
'5196',
'3668',
'3664',
'4681',
'1',
'1317',
'2847',
'4216',
'5275',
'5016',
'2792',
];

$ids = array_diff($ids, $service_accounts);

foreach ($ids as $id) {
// Load user by their user ID.
$user = $user_storage->load($id);
// Set the new password.
$user->setPassword(NULL);
$user->save();
}
};
Loading