-
Notifications
You must be signed in to change notification settings - Fork 343
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
Fix user update to raise exception when the username contains spaces #6895
base: master
Are you sure you want to change the base?
Fix user update to raise exception when the username contains spaces #6895
Conversation
@@ -487,6 +488,8 @@ func (u *CurrentUserUpdateRequestUser) UnmarshalAndValidate(user *User) error { | |||
errs = append(errs, fmt.Errorf("username: %w", err)) | |||
} else if user.Username == nil || *user.Username == "" { | |||
errs = append(errs, errors.New("username: cannot be null or empty string")) | |||
} else if strings.Contains(*user.Username, " ") { | |||
errs = append(errs, errors.New("username: cannot contain spaces")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since in older versions of Traffic Ops, it was possible to have users with spaces in their usernames, it's a breaking change to the API to no longer allow that. As such, that change cannot be made in APIv2 or v3.
However, I think a better solution than returning an error when the username contains spaces is to simply change the form validation in Traffic Portal to allow spaces, since the API already does. That also allows you to avoid the mess of API versioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if the condition defined in line 491 is true, I would need to change the form validation in the Traffic Portal?
If yes, where can I find the part of form validation in Traffic Portal?
And would I need to make the change for the form validation from the Go code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controller for the user details page view can be found at traffic_portal/app/src/common/modules/form/user/FormUserController.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controller for the user details page view can be found at
traffic_portal/app/src/common/modules/form/user/FormUserController.js
Alright, I'll look into that file. Thanks!
* Fixed bug in v2 test * Added tests for v3 and v4 API
This PR fixes #4240 by adding checks to raise an exception when the username contains spaces.
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
Run TrafficOps integration tests
If this is a bugfix, which Traffic Control versions contained the bug?
PR submission checklist