Conversation
| pattern := `^[a-zA-Z0-9]{1,255}$` | ||
| re := regexp.MustCompile(pattern) | ||
| return re.MatchString(username) | ||
| return len(username) >= 1 && len(username) <= 255 && !strings.ContainsAny(username, `,"~#%$`) |
There was a problem hiding this comment.
Yes, it meets the username validators, but it also satisfy certain requirements outlined in the issue #195.
There was a problem hiding this comment.
Just to confirm, should I add space trimming and an empty-check to the username validation here to fully meet issue #195 requirements, or handle that separately?
There was a problem hiding this comment.
I think it would be better to validate and trim spaces in the input fields here.
Signed-off-by: Roaster05 <krishnamadhwani2@gmail.com> Signed-off-by: Roaster05 <100672872+Roaster05@users.noreply.github.com>
Signed-off-by: Roaster05 <100672872+Roaster05@users.noreply.github.com>
|
reverting back as test fail. |
| pattern := `^[a-zA-Z0-9]{1,255}$` | ||
| re := regexp.MustCompile(pattern) | ||
| return re.MatchString(username) | ||
| username = strings.TrimSpace(username) |
There was a problem hiding this comment.
this code may not work as expected. If you enter harbor-cli with extra spaces, the strings.TrimSpace(username) doesn't properly store the value in the login.LoginView variable. Could you please fix this if you still want to continue? @Roaster05
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
This reverts commit d059ef2. Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
The username validator previously implemented only allowed alphanumeric characters, which resulted in rejecting valid usernames accepted by the server, such as
harbor-cli. This inconsistency also caused failures in login tests.To resolve this, the current implementation of the validator has been aligned with the server's username validation criteria. You can view the server-side validator here.
This PR references issue #234