2 Replies Latest reply on Sep 5, 2008 8:40 PM by jk;l jkl;

    Automatic login upon successful user registration

    jk;l jkl; Expert

      What’s the proper way to implement functionality where a successfully-registered user is immediately logged in? When directly attempting to log in, everything works as expected. However, when attempting to automatically log someone in upon registration of their new user account, it fails.

      At the end of my registration method (at the point where registration is successful), I call identity.login() whose underlying authenticate-method uses EntityManager to search for whether a user with the supplied username/password exists in the database. This search fails, returning no matching user record, even though the user has successfully registered and their user record has been physically written to the database!

      Before trying that search, I tried calling EntityManager’s clear() and flush() methods, but no luck. I didn’t expect that to work anyways, because the record has already been written to the database at this point - why can’t this search see that the record already exists?

      What’s the proper way to implement such functionality? Thanks.