论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Sid L
Auto Login Hook - Redirect to error page if authentication fails
2010年12月31日 下午9:53
答复

Sid L

等级: Junior Member

帖子: 28

加入日期: 2010年12月2日

最近的帖子

I have an application developed in liferay. Now I need to
provide a link on an external site to my app.

I have written a hook ( class extending from AutoLogin) which gets called when any request is being made.
In the login method of my class, I have a logic to authenticate the request parameters sent with the request.

Now what I want to achieve is, incase the authentication fails, I want to redirect the user to a error page.
Currently I am throwing an 'AutoLoginException' incase the validation fails. However it still redirects me to my desired page instead of error page.

Any suggestions on how this can be achieved?
Jelmer Kuperus
RE: Auto Login Hook - Redirect to error page if authentication fails
2011年1月1日 上午9:22
答复

Jelmer Kuperus

等级: Liferay Legend

帖子: 1192

加入日期: 2010年3月10日

最近的帖子

You can try doing this when authentication fails in your AutoLogin.login implementation

1request.setAttribute(AutoLogin.AUTO_LOGIN_REDIRECT, "http://www.yourhost.com/somerrorpage.html");
2return null;


And not throw the exception. Looking at the code of AutoLoginFilter that should work. But its kind of ugly
Sid L
RE: Auto Login Hook - Redirect to error page if authentication fails
2011年1月3日 上午3:51
答复

Sid L

等级: Junior Member

帖子: 28

加入日期: 2010年12月2日

最近的帖子

Thanks a lot . This solution worked for me
gofri _
RE: Auto Login Hook - Redirect to error page if authentication fails
2011年1月28日 上午3:25
答复

gofri _

等级: Junior Member

帖子: 92

加入日期: 2007年3月2日

最近的帖子

I have similar question - is there a way to redirect users to another page when authentication fails?
I mean with hook.
Faris Abdulla
RE: Auto Login Hook - Redirect to error page if authentication fails
2011年1月28日 上午7:12
答复

Faris Abdulla

等级: Regular Member

帖子: 183

加入日期: 2009年9月1日

最近的帖子

The login portlet returns to same page when authentication fails. The LoginAction throws exception to the login.jsp.

You can either use your own LoginAction just changing the struts action path. See this wiki for overriding the struts action using hooks.
gofri _
RE: Auto Login Hook - Redirect to error page if authentication fails
2011年1月28日 上午7:53
答复

gofri _

等级: Junior Member

帖子: 92

加入日期: 2007年3月2日

最近的帖子

10x,
I was thinking almost the same, but cannot make it work (I don't know Struts very well).
I created Custom class that extends LoginAction. Can someone give me hints how to use it? I mean
1. Should I write it as ext-service and place .jar in /lib/ext folder? Or I can use it in a hook?
2. What exactly should I change in struts action paths.
Jelmer Kuperus
RE: Auto Login Hook - Redirect to error page if authentication fails
2011年1月28日 上午11:27
答复

Jelmer Kuperus

等级: Liferay Legend

帖子: 1192

加入日期: 2010年3月10日

最近的帖子

You mean if you use the regular login portlet ?

Hmm if the page you want to redirect to also has the login portlet on it you can override login.jsp in a jsp hook and change the action url of the form to

<liferay-portlet:actionURL plid="THE PAGE ID GOES HERE" secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="loginURL"?
<portlet:param name="saveLastPath" value="0" />
<portlet:param name="struts_action" value="/login/login" />
</liferay-portlet:actionURL>

That way the error messages will be displayed in the login portlet of the other page

If the page you want to redirect to does not contain a login portlet then i think all you can do is extend LoginAction in an ext plugin and do a redirect if there is an error eg. check for !SessionErrors.isEmpty()
gofri _
RE: Auto Login Hook - Redirect to error page if authentication fails
2011年1月28日 上午11:03
答复

gofri _

等级: Junior Member

帖子: 92

加入日期: 2007年3月2日

最近的帖子

10x a lot!