Skip to content
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

UX: The username suggestion is invalid #73

Closed
ralgozino opened this issue Aug 13, 2021 · 6 comments · Fixed by #76
Closed

UX: The username suggestion is invalid #73

ralgozino opened this issue Aug 13, 2021 · 6 comments · Fixed by #76
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@ralgozino
Copy link
Member

When creating a new user in Permission Manager, the username field suggests as an example Jane Doe, but if you write that you get an error message saying that the username is not valid:
Screenshot 2021-08-13 at 10 11 26
Screenshot 2021-08-13 at 10 15 28

@ralgozino ralgozino added enhancement New feature or request good first issue Good for newcomers labels Aug 13, 2021
@ralgozino
Copy link
Member Author

also, "[...] dots and dashes and numbers" shuold be "[...] dots, dashes and numbers"

@RhnSharma
Copy link
Contributor

I would like to take this one.

@ralgozino
Copy link
Member Author

The PR didn't fix the issue. The placeholder problem is still present.

@ralgozino ralgozino reopened this Sep 15, 2021
@angelbarrera92
Copy link
Contributor

I think the problem is not only about the tooltip or the placeholder:

1st issue: The place holder "Jane Doe" is an invalid username. Consider using a valid one like: jane.doe.
2nd issue: The validation is incorrect. Backend and frontend are not checking the same regex pattern. In addition, the tooltip is incorrect right now.

Frontend:

    if (
      !username.match(/^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)$/)) {
      setUsernameError(`user can only contain lowercase letters, dots, dashes and numbers`)
      return false
    }

Backend:

const validUsernameRegex = "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$"

var invalidUsernameError = `username must be DNS-1123 compliant, it must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'gino.mycompany', regex used for validation is ` + validUsernameRegex

func isValidUsername(username string) (valid bool) {
	re := regexp.MustCompile(validUsernameRegex)
	return re.MatchString(username)
}

We must align these patterns

@divanikus
Copy link

For some reason it doesn't accept names with dot in the middle, despite of tooltip saying jane.doe is allowed.

image

Running latest v1.7.1-rc1

@DesSolo
Copy link

DesSolo commented Sep 1, 2023

#182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants