Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Rajeev K
Redirect into portal after authentication by authenticateByEmailAddress(..)
November 7, 2013 12:53 AM
Answer

Rajeev K

Rank: Regular Member

Posts: 214

Join Date: June 18, 2009

Recent Posts

Hi,

I am using 6.1.1 CE

I want to log the user in the portal on-click of a button on the home page. Similar to what happens on the Sign-in portlet.

So on my custom portlet user will type in username & password & then I need to validate it & then redirect into the portal.

How can I do this?

Will UserLocalServiceUtil.authenticateByEmailAddress(); help me? This only validates but not redirects?
Jose Jimenez
RE: Redirect into portal after authentication
November 6, 2013 11:18 PM
Answer

Jose Jimenez

LIFERAY STAFF

Rank: Regular Member

Posts: 151

Join Date: August 22, 2012

Recent Posts

Hi Rajeek,

Take a look in to the code of the native login portlet https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portlet/login/action/LoginAction.java#L181

Also you can change the login portlet and configure your custom login portlet as the default login portlet in portal-ext.properties https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/portal.properties#L3627

You have to take in account that all this code is the current branch in development, take a look in to the code of the version you are using.

I hope this information helps you,

Kind regards!
Jose
Jose Jimenez
RE: Redirect into portal after authentication
November 6, 2013 11:47 PM
Answer

Jose Jimenez

LIFERAY STAFF

Rank: Regular Member

Posts: 151

Join Date: August 22, 2012

Recent Posts

Hi again,

I forget tell you that if you only want to redirect after login to a custom page, you don't need to implement a login portlet, you can do it with a hook setting a landing page action in properties:

login.events.post=com.liferay.portal.events.CustomDefaultLandingPageAction

And adding the class com.liferay.portal.events.CustomDefaultLandingPageAction with the logic to return the page.

Also you can take a look into one example in the portal code, just search for the class com.liferay.portal.events.DefaultLandingPageAction

Kind regards!
Jose
Rajeev K
RE: Redirect into portal after authentication
November 7, 2013 10:37 PM
Answer

Rajeev K

Rank: Regular Member

Posts: 214

Join Date: June 18, 2009

Recent Posts

Hi Jose,

All I want to do is redirect user in the portal.

What should I do in the below if (isAuthenticated == 1){ }


 1int isAuthenticated = UserLocalServiceUtil
 2                            .authenticateByEmailAddress(
 3                                    themeDisplay.getCompanyId(),
 4                                    form.getEmailAddress(),
 5                                    form.getPassword(), headerMap,
 6                                    parameterMap, resultsMap);
 7                    if (isAuthenticated == 1){
 8                                                 //need to login to portal & then redirect from here
 9                                               }
venka reddy
RE: Redirect into portal after authentication
November 7, 2013 1:13 AM
Answer

venka reddy

Rank: Regular Member

Posts: 231

Join Date: March 23, 2011

Recent Posts

Define "Default Landing Page" in COntrol Panel --->Portal setting where you redirects as something like (/group/aaaa/yyyy)

and put below logic in your class in if loop as it redirects to /group/aaaa/yyyy

String defaultPagePath = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
PropsKeys.DEFAULT_LANDING_PAGE_PATH);

response.sendRedirect(defaultPagePath);

Let me know if you any other
Rajeev K
RE: Redirect into portal after authentication
November 7, 2013 1:25 AM
Answer

Rajeev K

Rank: Regular Member

Posts: 214

Join Date: June 18, 2009

Recent Posts

Hi Venka,

This just redirects to the default landing page.

I want to login to the site & then redirect.

There is some method to be called...may be LoginUtil.login(...) ??
Rajeev K
RE: Redirect into portal after authentication
November 7, 2013 10:38 PM
Answer

Rajeev K

Rank: Regular Member

Posts: 214

Join Date: June 18, 2009

Recent Posts

Has anyone done this before?

Try to login to the portal from inside a custom portlet Action?
Rajeev K
RE: Redirect into portal after authentication
November 7, 2013 11:01 PM
Answer

Rajeev K

Rank: Regular Member

Posts: 214

Join Date: June 18, 2009

Recent Posts

José A. Jiménez:
Hi Rajeek,

Take a look in to the code of the native login portlet https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portlet/login/action/LoginAction.java#L181

Also you can change the login portlet and configure your custom login portlet as the default login portlet in portal-ext.properties https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/portal.properties#L3627

You have to take in account that all this code is the current branch in development, take a look in to the code of the version you are using.

I hope this information helps you,

Kind regards!
Jose


Hi Jose,

I saw https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portlet/login/action/LoginAction.java#L181

I am not able to compile my code because of this:-
- The import com.liferay.portal.util.PropsValues cannot be resolved
- The import com.liferay.portlet.PortletURLImpl cannot be resolved
- The import com.liferay.portlet.login cannot be resolved
- LoginUtil cannot be resolved
- PropsValues cannot be resolved
- PortletURLImpl cannot be resolved to a type

What needs to be imported?
I know we cannot include portal-impl.jar in our war as its not allowed.