Skip to content

Commit

Permalink
Console username cleanup, runtime override expiry docs fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyro committed Jul 28, 2022
1 parent aa86ffe commit fcd0073
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/config.go
Expand Up @@ -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"))
Expand Down
4 changes: 4 additions & 0 deletions server/console_user.go
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions server/runtime_javascript_nakama.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit fcd0073

Please sign in to comment.