Skip to content

Commit

Permalink
Merge pull request #16805 from martenson/purge-unampass
Browse files Browse the repository at this point in the history
move the email and username redacting from the role loop
  • Loading branch information
mvdbeek authored Oct 9, 2023
2 parents a33ea00 + ed519e6 commit 985c181
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/galaxy/managers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def purge(self, user, flush=True):
# Deleting multiple times will re-hash the username/email
email_hash = new_secure_hash_v2(user.email + pseudorandom_value)
uname_hash = new_secure_hash_v2(user.username + pseudorandom_value)
# We must also redact username
# Redact all roles user has
for role in user.all_roles():
if self.app.config.redact_username_during_deletion:
role.name = role.name.replace(user.username, uname_hash)
Expand All @@ -225,11 +225,12 @@ def purge(self, user, flush=True):
if self.app.config.redact_email_during_deletion:
role.name = role.name.replace(user.email, email_hash)
role.description = role.description.replace(user.email, email_hash)
user.email = email_hash
user.username = uname_hash
private_role.name = email_hash
private_role.description = f"Private Role for {email_hash}"
self.session().add(private_role)
# Redact user's email and username
user.email = email_hash
user.username = uname_hash
# Redact user addresses as well
if self.app.config.redact_user_address_during_deletion:
user_addresses = (
Expand Down

0 comments on commit 985c181

Please sign in to comment.