@vladmustiata This is not a bug but by design. There’s a few details to consider on how Nakama stores and manages usernames. The session token for a user contains a number of cached fields which make values like user ID, username, etc available without a database request or centralized session cache.
An example of the contents of a Nakama session token:
You can see the
"uid" in the decoded token.
When the username is updated in the account for the player you should then refresh their token with a new authentication (this will be easier in newer releases of the server - see https://github.com/heroiclabs/nakama/pull/466) which will return a new session token for that user.
Please note that even with the username updated and reflected into the session token it will not cause the leaderboard/tournament records to be updated which have already been written. As you can imagine to update all score records for the user would be expensive with the database. If you want to achieve this you can manage it yourself with an after hook on the AccountUpdate request which writes 0 value scores to the leaderboards for the player - in this case the username field will be updated but based on the score operator for the leaderboard the new score can just be ignored.
These design decisions ensure that the system scales exceptionally well and limits the IO pressure on the database.
Hope this helps.