我正在使用Liferay 6.0.我有多个组织,并希望根据组织更改用户的登录页面.
我是Liferay的新手,试图找到一些建议,但找不到正确的答案.
是否可以使用开箱即用的工具?没有编写代码?
如果需要代码,最佳解决方案是什么?
请帮忙,谢谢
在Liferay 6中,可以使用属性设置默认登录页面default.landing.page.path,但它是影响门户网站实例中每个用户的常规设置.
要根据组织更改用户的登录页面,需要"后登录"门户事件的自定义操作.最终,该属性login.events.post必须指向自定义登录操作:
login.events.post=yourcode.CustomLandingPageAction
Run Code Online (Sandbox Code Playgroud)
有两种方法可以实现这一目标:
一种自定义操作,使组织用户登陆组织的私有页面(从上面的链接派生):
public class CustomLandingPageAction extends Action {
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
try {
doRun(request, response);
} catch (Exception e) {
throw new ActionException(e);
}
}
protected void doRun(HttpServletRequest request, HttpServletResponse response)
throws Exception {
long companyId = PortalUtil.getCompanyId(request);
String path = PrefsPropsUtil.getString(companyId, PropsKeys.DEFAULT_LANDING_PAGE_PATH);;
if (Validator.isNull(path)) {
User user = PortalUtil.getUser(request);
String language = user.getLocale().getLanguage();
List<Organization> orgList = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId());
// Default landing page: go to the path in DefaultLandingPageAction
LastPath lastPath = new LastPath(StringPool.BLANK, path, new HashMap<String, String[]>());
// But if the logged user is in some community
if (!orgList.isEmpty()){
// and such community has a private page
if (orgList.get(0).hasPrivateLayouts()) {
// go there instead
String orgFriendlyURL = orgList.get(0).getGroup().getFriendlyURL();
String myPath = "/" + language + "/group" + orgFriendlyURL;
lastPath = new LastPath(StringPool.BLANK, myPath);
}
}
HttpSession session = request.getSession();
session.setAttribute(WebKeys.LAST_PATH, lastPath);
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6545 次 |
| 最近记录: |