scalasecuresocial

Securesocial play 2.3 master - update user


I added securesocial 2.3 to my project and it works well. SecuredAction offers easy user access (request.user) and everything is fine until properties of my user change. I have no idea how to tell the securesocial that the users fields have updated or how to give him different user object to associate with.

How can I do that or what am I doing wrong?

Thanks, Lovro


Solution

  • There is no 2.3 version of SecureSocial. I assume you are using Play 2.3 and master-SNAPSHOT or 3.0-M1 here.

    Once a user is authenticated SecureSocial uses an Authenticator to keep track of the user session. The module has 2 built in authenticators: CookieAuthenticator and HttpHeaderAuthenticator. Both implementations extend StoreBackedAuthenticator which uses an AuthenticatorStore to save/retrieve instances of the authenticators.

    The default store implementation uses a CacheService. So if you change properties of your users and want those reflected you need to invoke something like the following:

    val updatedUser = <some code that changes your user>
    request.authenticator.updateUser(updatedUser)