Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Aryan sds
Login programitically & logout programitically just after creation of user
2. April 2013 22:36
Antwort

Aryan sds

Rang: Junior Member

Nachrichten: 57

Eintrittsdatum: 24. April 2012

Neue Beiträge

Hello I have created a user pragmatically using addUser() method . After user creation I want to login this user pragmatically itself .

I have tried this way...

1MethodKey key = new MethodKey("com.liferay.portlet.login.util.LoginUtil", "login", HttpServletRequest.class, HttpServletResponse.class, String.class, String.class, boolean.class, String.class);
2PortalClassInvoker.invoke(false, key, new Object[] { PortalUtil.getHttpServletRequest(actionRequest), PortalUtil.getHttpServletResponse(actionResponse), "user@test.com", "password", false, CompanyConstants.AUTH_TYPE_EA});



But I am not getting any error, and even if I am trying to print current logged in user , I am getting default liferay account details with email id as default@liferay.com which is not correct.

So is there any way to login & logout admin pragmatically , Or tel me if I am missing any process to login admin pragmatically ?.

Thanks,
Aryan sds.
Arvind Gupta
RE: Login programitically just after creation of user
2. April 2013 22:28
Antwort

Arvind Gupta

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 17. Dezember 2012

Neue Beiträge

How are you getting the loggedIn user details?
Aryan sds
RE: Login programitically just after creation of user
2. April 2013 22:32
Antwort

Aryan sds

Rang: Junior Member

Nachrichten: 57

Eintrittsdatum: 24. April 2012

Neue Beiträge

Using liferay theme object.

1ThemeDisplay themeDisplay = (ThemeDisplay) FacesContext
2                            .getCurrentInstance().getExternalContext()
3                                           
4System.out.println("user id looged in4444 "+themeDisplay.getUser().getEmailAddress());
Arvind Gupta
RE: Login programitically just after creation of user
2. April 2013 23:05
Antwort

Arvind Gupta

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 17. Dezember 2012

Neue Beiträge

User is set in ThemeDisplay in "ServicePreAction" which is called before any action. Current user in ThemeDisplay is default user, it will update the user once you forward to some action or new page.