summaryrefslogtreecommitdiffstats
path: root/model/user.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-03 12:04:15 -0500
committerChristopher Speller <crspeller@gmail.com>2017-03-03 12:04:15 -0500
commit2e911b77c3386833f8f0cea82c7b6b3e5583a08e (patch)
tree63c515b41e5abf024e94658554a02acaf40710df /model/user.go
parent09ee8e8a58df9526c619ac80cd76bca8cf4ca107 (diff)
downloadchat-2e911b77c3386833f8f0cea82c7b6b3e5583a08e.tar.gz
chat-2e911b77c3386833f8f0cea82c7b6b3e5583a08e.tar.bz2
chat-2e911b77c3386833f8f0cea82c7b6b3e5583a08e.zip
Usernames must start with a letter (#5581)
Diffstat (limited to 'model/user.go')
-rw-r--r--model/user.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/model/user.go b/model/user.go
index 2412c2ec7..f380a7550 100644
--- a/model/user.go
+++ b/model/user.go
@@ -10,6 +10,7 @@ import (
"net/http"
"regexp"
"strings"
+ "unicode"
"unicode/utf8"
"golang.org/x/crypto/bcrypt"
@@ -142,7 +143,7 @@ func (u *User) PreSave() {
}
if u.Username == "" {
- u.Username = NewId()
+ u.Username = "n" + NewId()
}
if u.AuthData != nil && *u.AuthData == "" {
@@ -572,6 +573,10 @@ func IsValidUsername(s string) bool {
return false
}
+ if !unicode.IsLetter(rune(s[0])) {
+ return false
+ }
+
for _, restrictedUsername := range restrictedUsernames {
if s == restrictedUsername {
return false