Skip to content

Strip leading and trailing whitespace from user's name

What does this MR do and why?

Related to #342133 (closed)

Previously it was possible for an Admin to create a user with leading/trailing whitespace in the name. If you tried to delete the user it was required to enter the name with whitespace in the confirmation input. To fix this bug, this MR does the following:

  1. Uses the strip_attributes! concern to strip leading and trailing whitespace from the name of newly created users.
  2. Strips whitespace from existing user's names in the app/assets/javascripts/admin/users/components/modals/delete_user_modal.vue component.

Screenshots or screen recordings

Before After
Screen_Shot_2021-12-14_at_3.32.02_PM Screen_Shot_2021-12-14_at_3.36.12_PM

How to set up and validate locally

  1. Sign in as an Admin
  2. Navigate to /admin/users/new and create a user with leading and/or trailing whitespace in the name
  3. Find the user in /admin/users and click the Delete user button in the dropdown. Screen_Shot_2021-12-14_at_3.39.05_PM
  4. The username should be displayed without the whitespace.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Hegman

Merge request reports