Skip to content

Commit

Permalink
Revert "MM-54502 - Update regex to force first character to be alpha … (
Browse files Browse the repository at this point in the history
mattermost#28860)

* Revert "MM-54502 - Update regex to force first character to be alpha (mattermost#24675)"

This reverts commit 08ed72f.

* update tests for reverted PR

* Revert "update tests for reverted PR"

This reverts commit c1cf549.

* Revert "Revert "MM-54502 - Update regex to force first character to be alpha (mattermost#24675)""

This reverts commit 6920b97.

* only revert important parts, not tests

---------

Co-authored-by: Mattermost Build <[email protected]>
  • Loading branch information
sbishel and mattermost-build authored Oct 24, 2024
1 parent 707144d commit 108efac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions server/public/model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,7 @@ func HashPassword(password string) (string, error) {
}

var validUsernameChars = regexp.MustCompile(`^[a-z0-9\.\-_]+$`)
var validUsername = regexp.MustCompile(`^[a-z][a-z0-9\.\-_]*$`)
var validUsernameCharsForRemote = regexp.MustCompile(`^[a-z][a-z0-9\.\-_:]*$`)
var validUsernameCharsForRemote = regexp.MustCompile(`^[a-z0-9\.\-_:]*$`)

var restrictedUsernames = map[string]struct{}{
"all": {},
Expand All @@ -991,7 +990,7 @@ func IsValidUsername(s string) bool {
return false
}

if !validUsername.MatchString(s) {
if !validUsernameChars.MatchString(s) {
return false
}

Expand Down
6 changes: 3 additions & 3 deletions server/public/model/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ var usernames = []usernamesTest{
{"spin-punch", true, true},
{"sp", true, true},
{"s", true, true},
{"1spin-punch", false, false},
{"-spin-punch", false, false},
{".spin-punch", false, false},
{"1spin-punch", true, true},
{"-spin-punch", true, true},
{".spin-punch", true, true},
{"Spin-punch", false, false},
{"spin punch-", false, false},
{"spin_punch", true, true},
Expand Down

0 comments on commit 108efac

Please sign in to comment.