Foren

Registering and logging in in one request for a custom portlet

thumbnail
Adam Victor Nazareth Brandizzi, geändert vor 11 Jahren.

Registering and logging in in one request for a custom portlet

Junior Member Beiträge: 67 Beitrittsdatum: 30.04.10 Neueste Beiträge
Hello, all!

We have a custom portlet for user registration. To register a new user was relatively easy but we are struggling to make the recently registered user the logged in one just after its registration. We used UserLocalServiceUtil.authenticateByScreenName() but apparently it does not do all the magic. We longed for using the forbidden LoginUlti.login() method as well emoticon Currently, we are cogitating to send a request to the login action, but this seems to be a bit annoying to do...

How would you do it?

Thanks in advance!
thumbnail
Sandeep Nair, geändert vor 11 Jahren.

RE: Registering and logging in in one request for a custom portlet (Antwort)

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Hi,

I would use an auto login hook to automatically login after registration. Make username/userid available to the autologin hook class either using session or cookie after registration process is over

For a simple example of how AutoLoginHook class should be see RememberMeAutoLogin(this automatically logs in user if user has selected remember me checkbox while first time login. Just sets a cookie) or ParameterAutoLogin(This authenticates user if username and password are passed in request url).

Regards,
Sandeep