留言板

Get UserId of logged in user without request object

Hussain Shaikh,修改在11 年前。

Get UserId of logged in user without request object

Junior Member 帖子: 44 加入日期: 12-6-7 最近的帖子
Hi,
How can i get current user's userId without a request object?
Thanks
thumbnail
Mika Koivisto,修改在11 年前。

RE: Get UserId of logged in user without request object

Liferay Legend 帖子: 1519 加入日期: 06-8-7 最近的帖子
You can always access PrincipalThreadLocal just remember that any scheduled tasks won't have any user associated with them.
Rahul Sharma,修改在11 年前。

RE: Get UserId of logged in user without request object

Junior Member 帖子: 59 加入日期: 12-1-11 最近的帖子
Hi Hussain,

You can use ThemeDisplay object to get the user's userID, such as themeDisplay.getUserId().

Hope this will help you.

Regards,
Rahul
thumbnail
Mika Koivisto,修改在11 年前。

RE: Get UserId of logged in user without request object

Liferay Legend 帖子: 1519 加入日期: 06-8-7 最近的帖子
Rahul, usually when you don't have request you don't have ThemeDisplay either.