@@ -20,13 +20,14 @@ import (
20
20
"database/sql"
21
21
"encoding/json"
22
22
"errors"
23
- "github.com/jackc/pgconn"
24
23
"net/http"
25
24
"regexp"
25
+ "strings"
26
26
"unicode"
27
27
28
28
"github.com/gofrs/uuid"
29
29
"github.com/heroiclabs/nakama/v3/console"
30
+ "github.com/jackc/pgconn"
30
31
"go.uber.org/zap"
31
32
"golang.org/x/crypto/bcrypt"
32
33
"google.golang.org/grpc/codes"
@@ -43,6 +44,7 @@ func (s *ConsoleServer) AddUser(ctx context.Context, in *console.AddUserRequest)
43
44
} else if len (in .Username ) < 3 || len (in .Username ) > 20 || ! usernameRegex .MatchString (in .Username ) {
44
45
return nil , status .Error (codes .InvalidArgument , "Username must be 3-20 long sequence of alphanumeric characters _ or . and cannot start and end with _ or ." )
45
46
}
47
+ in .Username = strings .ToLower (in .Username )
46
48
47
49
if in .Username == "admin" || in .Username == s .config .GetConsole ().Username {
48
50
return nil , status .Error (codes .InvalidArgument , "Username cannot be the console configured username" )
@@ -53,11 +55,12 @@ func (s *ConsoleServer) AddUser(ctx context.Context, in *console.AddUserRequest)
53
55
} else if len (in .Email ) < 3 || len (in .Email ) > 254 || ! emailRegex .MatchString (in .Email ) || invalidCharsRegex .MatchString (in .Email ) {
54
56
return nil , status .Error (codes .InvalidArgument , "Not a valid email address" )
55
57
}
58
+ in .Email = strings .ToLower (in .Email )
56
59
57
60
if in .Password == "" {
58
61
return nil , status .Error (codes .InvalidArgument , "Password is required" )
59
62
} else if ! isValidPassword (in .Password ) {
60
- return nil , status .Error (codes .InvalidArgument , "Password must be at least 6 characters long and contain 1 number and 1 upper case character" )
63
+ return nil , status .Error (codes .InvalidArgument , "Password must be at least 8 characters long and contain 1 number and 1 upper case character" )
61
64
}
62
65
63
66
inviterUsername := ctx .Value (ctxConsoleUsernameKey {}).(string )
@@ -168,7 +171,7 @@ func (s *ConsoleServer) dbDeleteConsoleUser(ctx context.Context, username string
168
171
}
169
172
170
173
func isValidPassword (pwd string ) bool {
171
- if len (pwd ) < 6 {
174
+ if len (pwd ) < 8 {
172
175
return false
173
176
}
174
177
var number bool
0 commit comments