Fix user update to raise exception when the username contains spaces#6895
Fix user update to raise exception when the username contains spaces#6895hritvikpatel4 wants to merge 2 commits into
Conversation
| } 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.
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.
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.
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.
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