From 5398c82e1b80c3160974e01afabbfd1c2a2420a7 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 18 Apr 2017 17:37:25 -0400 Subject: Revert "Usernames must start with a letter (#5581)" This reverts commit 2e911b77c3386833f8f0cea82c7b6b3e5583a08e. --- model/user.go | 7 +------ model/user_test.go | 12 ++++++------ 2 files changed, 7 insertions(+), 12 deletions(-) (limited to 'model') diff --git a/model/user.go b/model/user.go index 2c2ba734b..7cb3d0b70 100644 --- a/model/user.go +++ b/model/user.go @@ -10,7 +10,6 @@ import ( "net/http" "regexp" "strings" - "unicode" "unicode/utf8" "golang.org/x/crypto/bcrypt" @@ -152,7 +151,7 @@ func (u *User) PreSave() { } if u.Username == "" { - u.Username = "n" + NewId() + u.Username = NewId() } if u.AuthData != nil && *u.AuthData == "" { @@ -582,10 +581,6 @@ func IsValidUsername(s string) bool { return false } - if !unicode.IsLetter(rune(s[0])) { - return false - } - for _, restrictedUsername := range restrictedUsernames { if s == restrictedUsername { return false diff --git a/model/user_test.go b/model/user_test.go index 3eb931f5d..fc153248f 100644 --- a/model/user_test.go +++ b/model/user_test.go @@ -97,9 +97,9 @@ func TestUserIsValid(t *testing.T) { t.Fatal() } - user.Username = "n" + NewId() - user.Email = strings.Repeat("a", 129) - if err := user.IsValid(); !HasExpectedUserIsValidError(err, "email", user.Id) { + user.Username = NewId() + user.Email = strings.Repeat("01234567890", 20) + if err := user.IsValid(); err == nil { t.Fatal() } @@ -204,9 +204,9 @@ var usernames = []struct { {"spin-punch", true}, {"sp", true}, {"s", true}, - {"1spin-punch", false}, - {"-spin-punch", false}, - {".spin-punch", false}, + {"1spin-punch", true}, + {"-spin-punch", true}, + {".spin-punch", true}, {"Spin-punch", false}, {"spin punch-", false}, {"spin_punch", true}, -- cgit v1.2.3-1-g7c22