diff --git a/server/config.go b/server/config.go index d16dc34a2..8ea86dc2c 100644 --- a/server/config.go +++ b/server/config.go @@ -155,8 +155,8 @@ func CheckConfig(logger *zap.Logger, config Config) map[string]string { if config.GetConsole().IdleTimeoutMs < 1 { logger.Fatal("Console idle timeout milliseconds must be >= 1", zap.Int("console.idle_timeout_ms", config.GetConsole().IdleTimeoutMs)) } - if config.GetConsole().Username == "" { - logger.Fatal("Console username must be set", zap.String("param", "console.username")) + if config.GetConsole().Username == "" || !usernameRegex.MatchString(config.GetConsole().Username) { + logger.Fatal("Console username must be set and valid", zap.String("param", "console.username")) } if config.GetConsole().Password == "" { logger.Fatal("Console password must be set", zap.String("param", "console.password")) diff --git a/server/console_user.go b/server/console_user.go index e16cef234..e2e5a161b 100644 --- a/server/console_user.go +++ b/server/console_user.go @@ -43,6 +43,10 @@ func (s *ConsoleServer) AddUser(ctx context.Context, in *console.AddUserRequest) return nil, status.Error(codes.InvalidArgument, "Username must be 3-20 long sequence of alphanumeric characters _ or . and cannot start and end with _ or .") } + if in.Username == "admin" || in.Username == s.config.GetConsole().Username { + return nil, status.Error(codes.InvalidArgument, "Username cannot be the console configured username") + } + if in.Email == "" { return nil, status.Error(codes.InvalidArgument, "Email is required") } else if len(in.Email) < 3 || len(in.Email) > 254 || !emailRegex.MatchString(in.Email) || invalidCharsRegex.MatchString(in.Email) { diff --git a/server/runtime_javascript_nakama.go b/server/runtime_javascript_nakama.go index 80747ca54..6cf5664c1 100644 --- a/server/runtime_javascript_nakama.go +++ b/server/runtime_javascript_nakama.go @@ -5145,7 +5145,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardsGetId(r *goja.Runtime) func( // @param owner(type=string) The owner of the score to list records around. Mandatory field. // @param limit(type=number) Return only the required number of leaderboard records denoted by this limit value. // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. -// @param overrideExpiry(type=number) Records with expiry in the past are not returned unless within this defined limit. Must be equal or greater than 0. +// @param overrideExpiry(type=number, optional=true, default=0) Optionally retrieve records from previous resets by specifying the reset point in time in UTC seconds. Must be equal or greater than 0. // @return records(nkruntime.LeaderboardRecordList) The leaderboard records according to ID and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. func (n *runtimeJavascriptNakamaModule) leaderboardRecordsHaystack(r *goja.Runtime) func(goja.FunctionCall) goja.Value { @@ -5910,7 +5910,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentsGetId(r *goja.Runtime) func(g // @param ownerIds(type=string[], optional=true) Array of owner IDs to filter results by. Optional. // @param limit(type=number, optional=true Return only the required number of tournament records denoted by this limit value. Max is 10000. // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. -// @param overrideExpiry(type=number, optional=true) Records with expiry in the past are not returned unless within this defined limit. Must be equal or greater than 0. +// @param overrideExpiry(type=number, optional=true, default=0) Optionally retrieve records from previous resets by specifying the reset point in time in UTC seconds. Must be equal or greater than 0. // @return records(nkruntime.LeaderboardRecord) A page of tournament records. // @return ownerRecords(nkruntime.LeaderboardRecord) A list of owner tournament records (empty if the owners input parameter is not set). // @return prevCursor(string) An optional previous page cursor that can be used to retrieve the previous page of records (if any).