[英]How does Liferay login work?
Just as the user jack wants to do in this post, I need to do a portlet that uses login through token authentication. 就像用户jack想要在这篇文章中做的一样,我需要做一个通过令牌认证使用登录的portlet。
As is stated there, portal-impl.jar
is unavailable for me to use, so LoginUtil.login
is unaccessible. 如此处所述,
portal-impl.jar
无法使用,因此LoginUtil.login
访问。
Additionally, adding functionality to the existing ext plugin
is almost out of the question because he's waaaay to 'dense', and creating another one is a bad practice. 另外,向现有的
ext plugin
添加功能几乎是不可能的,因为他不愿意“密集”,而创建另一个ext plugin
则是一种不好的做法。
So i chose to create my own login function based on the login()
logic in LoginUtil
. 因此,我选择根据
LoginUtil
的login()
逻辑创建自己的登录函数。 It's basically the same code but with the required portal-impl.jar
's properties stored locally (upgrade to a newer Liferay version is out of the question so I think it's ok to do that). 它基本上是相同的代码,但是具有所需的
portal-impl.jar
的属性存储在本地(升级到较新的Liferay版本是不可能的,因此我认为可以这样做)。
Everything seems to work fine, however I am not logged in and no error apperas in Tomcat. 一切似乎都工作正常,但是我没有登录,并且在Tomcat中没有错误提示。
Now, my problem is that I can't realise what piece of the code actually logs the user in. 现在,我的问题是我无法意识到实际上有哪段代码可以登录用户。
I assume it's this 我想就是这个
session.setAttribute("j_username", userIdString);
session.setAttribute("j_password", user.getPassword());
session.setAttribute("j_remoteuser", userIdString);
session.setAttribute(WebKeys.USER_PASSWORD, password);
PS : After my custom login method (which I repeat, it has the same code as LoginUtil's login method), if I put the following code : PS:如果我输入以下代码,则在我的自定义登录方法(重复执行,它具有与LoginUtil的登录方法相同的代码)之后:
ThemeDisplay td = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
User uu = td.getUser();
System.out.println("user = " + uu.getEmailAddress());
it will output user = default@liferay.com
, so the login is unsuccessful. 它将输出
user = default@liferay.com
,因此登录失败。
Where is the user logged in in that code?! 用户在哪里登录该代码?
PPS: in my portal-ext.properties, here are the following add-ons: PPS:在我的portal-ext.properties中,以下是附加组件:
auth.pipeline.enable.liferay.check=false
session.enable.persistent.cookies=true
session.enable.phishing.protection=false
session.disabled=false
session.test.cookie.support=true
My version of Liferay is 5.2.3. 我的Liferay版本是5.2.3。
Sorry, but my opinion, the better and simplest way is to create a new hook with AutoLogin funktion: How do I use autologin in liferay? 抱歉,我认为更好和最简单的方法是使用AutoLogin功能创建一个新钩子: 如何在liferay中使用自动登录?
ps: and then you are upgrade stable. ps:然后您就可以稳定升级了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.