username not updated

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Bathory
Posts: 54
Joined: 17 Sep 2011, 21:47

username not updated

Postby Bathory » 13 Jul 2013, 19:03

Hello,

When a user changes his username in server code I update the DB with the new name and use sender.setName to update the live user object.

However the client does not get this update, smartfox.mySelf.name still returns the old username.

I tried to use
getApi().getUserById(sender.getId()).setName(...) and got the same result.

I'm a bit surprised, I'm pretty sure I tested this before and at some point it worked, something must have changed. :)

Thank you
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: username not updated

Postby rjgtav » 14 Jul 2013, 23:11

Hello,

In order to successfully change the User's name, you have to do it at the Login time.
You can find more information at this documentation chapter, at 4) Change the user name at login time:
http://docs2x.smartfoxserver.com/Gettin ... wtos#item3

Cheers
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
brendan7
Posts: 43
Joined: 10 Feb 2014, 17:40

Re: username not updated

Postby brendan7 » 19 Aug 2015, 19:13

How would one do this if they are using the SignUpAssistantComponent and LoginAssistantComponent?

I have some handlers that need to get a user by their name, like this:

Code: Select all

User otherUser = this.getApi().getUserByName(other_name);


However, I noticed in the Zone Monitor that a recently signed-up user still has a username of "Guest#-XXXX".

I tried manually setting the name in the CustomSignUpPostProcessor like this:

Code: Select all

user.setName(un);
user.getSession().getSessionManager().setName(un);


But I am still getting null for getUserByName(name) until they exit the app and sign back in.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: username not updated

Postby Lapo » 20 Aug 2015, 09:17

Hi,
if you require a login name and a separate user name you will need those fields to be specified at registration time.

In other words your database will need those two fields, and your user registration interface will ask those details , which the SignUpAssistant will handle for you. (it's just a matter of configuring the necessary fields)

At login time you can require the "login name" to be used to sign in while user name will be assigned from another field in the DB.

This is explained in the LoginAssistant documentation:
http://docs2x.smartfoxserver.com/Develo ... -assistant

See the "A slightly more advanced case" section.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 18 guests