Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dbarkowsky
Copy link
Collaborator

🎯 Summary

PIMS-1378

Needed a way to update usernames in PIMS database.
Recommend testing this against your local database.
I've done some tests against DEV that seem to work so far.

The script does the following:

  1. Gets users from table in database
  2. For each user
    2a. Tries to find that user in Keycloak
    2b. Either updates their username or...
    • Deletes the user if the database allows
    • Disables the user if they database doesn't allow deletion (possible FK constraint)
    • Writes the failed updates to a failures.json file.

Changes

  • Added script in /tools/usernameUpdater for updating usernames

Testing

  1. Fill out the .env in the /tools/usernameUpdater folder according to the .env-template file. Use prod for the SSO_ENVIRONMENT, otherwise users from BCeID will not be detected (they've never logged in to DEV).
  2. Run the script with npm start.

🔰 Checklist

  • I have read and agree with the following checklist and am following the guidelines in our Code of Conduct document.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation where required.
  • I have tested my changes to the best of my ability.
  • My changes generate no new warnings.

@dbarkowsky
Copy link
Collaborator Author

Realizing that I should add a README for this. Please don't merge until I've added that.

Copy link
Collaborator

@TaylorFries TaylorFries left a comment

Choose a reason for hiding this comment

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

script runs as expected - no issues detected

@dbarkowsky dbarkowsky merged commit 3315957 into main Mar 11, 2024
@dbarkowsky dbarkowsky deleted the PIMS-1378-Username-Fix branch March 11, 2024 20:34
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.

3 participants