Updated username not refreshed in tournament records

Hello,
I’m having the following problen

  1. User with username “abc” updates his username to “def” (i’m using a runtime function to do this)
  2. User submits a ranking score
  3. Ranking score show the username “abc”

How to fix this? Thank you for your help

@lex Which SDK do you use? We’re about to release SDK updates (.NET and Unity are first) that include session refresh APIs to generate a session token with a new lifetime. This is important because as an optimization we cache the user ID and username for the user into their session token. This avoids a significant amount of database IO overhead with parts of the server APIs but means that a username could be stale when it’s changed with an account update.

You have two options to use:

  1. Follow what other game teams do right now and just reauthenticate the user after they update their username to something new. This will issue a new session token for the user that can be used to authorize requests like when they submit scores to the leaderboards, etc.

  2. Wait until the next release (should be completed before the end of next week) of the SDKs that will include a function you can use to refresh the user’s session. For example in Unity it will look like:

    var refreshedSession = await client.SessionRefreshAsync(session, null);
    

Hope this helps.

1 Like

Thanks!
I followed the option 1, and it works :wink:

I’m using Defold SDK by the way

1 Like

@lex I’ve made a note on the Defold client SDK issue tracker for us to add the new session refresh and IAP receipt validation functions.

I am new in nakama, me too.
I ran into the same problem, but my solution was to use DisplayName.
also because DisplayName does not need to be unique as opposed to Name which cannot be duplicated.
but using DisplayName introduces other problems as it is not directly supported by the server.
for leaderborts and chat I solved it by adding DisplayName value to metadata.
but in this way the code is not clean, when I change DisplayName value, I have to re write leaderborts and char in the server.
to overcome this, I thought of using the Name field with the value produced by the server at the first login and add a suffix which is the visible name, for example “dfvdvbshybv_name”, and have my own function that splits the two parts of the string.
my question is:

in the near future, will you introduce DisplayName in leaderborts and chat responses, clearly updating if changed, or Name will no longer be unique and will automatically update on the server?

PS
what is the sense of having user id and name, if they behave more or less the same way.

1 Like

@anon39851408 There’s no plan to change this behaviour. The 3 fields you speak about have different purposes:

  • user ID = A unique UUIDv4 type which cannot be changed.
  • username = A unique memorable name for the user that can be shown and shared between players.
  • display name = A non-unique name for the user which can be shown.

for leaderborts and chat I solved it by adding DisplayName value to metadata.

If you’d like to use the display name for the user in their leaderboard records this is the best pattern to use.

in the near future, will you introduce DisplayName in leaderborts and chat responses, clearly updating if changed, or Name will no longer be unique and will automatically update on the server?

There is no Name field in the server. I think you meant username. The username will always be unique per player and the display name will not be captured automatically into the leaderboard records or chat messages.

Is there a reason you cannot use the username field for the user in your game on the leaderboard records?

PS
what is the sense of having user id and name, if they behave more or less the same way.

A username can be changed by the user to another that is unique but a display name is non-unique for the user and so cannot be used to identify a specific player.

1 Like

> Is there a reason you cannot use the username field for the user in your game on the leaderboard records?

sorry yes, no Name, but username.
Not in particular, is that I hate applications where I cannot enter my user name because it is already used by another person.
modern applications no longer have this limit.
so, using leaderboard username it means it must be unique.

modern applications no longer have this limit.

I’m curious what modern applications are you referring to that don’t have this limit?

Nakama also does not have this limit which is why we have the display name field for the user. :wink:

just general comment, I not have a particular application in mind.
thanks for the clarification. :+1: