User Landing page validation based on roles
================================
Portal.properties
==================
login.events.post=com.agco.dealer.hook.events.controller.CustomLoginPostAction
liferay-hooks.xml
=================
<hook>
<portal-properties>portal.properties</portal-properties>
</hook>
package com.agco.dealer.hook.events.controller;
public class CustomLoginPostAction extends Action {
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
long companyId = themeDisplay.getCompanyId();
User user = themeDisplay.getUser();
long userId = user.getUserId();
List<Role> userRoles = RoleLocalServiceUtil.getUserRoles(user.getUserId());
for(Role role : userRoles) {
if(role.getName().equalsIgnoreCase("X")){
response.sendRedirect("/web/test");
}
if(role.getName().equalsIgnoreCase("Y")){
response.sendRedirect("/web/sample");
}
}
}
}
================================
Portal.properties
==================
login.events.post=com.agco.dealer.hook.events.controller.CustomLoginPostAction
liferay-hooks.xml
=================
<hook>
<portal-properties>portal.properties</portal-properties>
</hook>
package com.agco.dealer.hook.events.controller;
public class CustomLoginPostAction extends Action {
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
long companyId = themeDisplay.getCompanyId();
User user = themeDisplay.getUser();
long userId = user.getUserId();
List<Role> userRoles = RoleLocalServiceUtil.getUserRoles(user.getUserId());
for(Role role : userRoles) {
if(role.getName().equalsIgnoreCase("X")){
response.sendRedirect("/web/test");
}
if(role.getName().equalsIgnoreCase("Y")){
response.sendRedirect("/web/sample");
}
}
}
}
List articles = JournalArticleLocalServiceUtil.getArticles();
ReplyDeleteSystem.out.println("All Articles"+articles);
/* JournalArticle ja = null;
System.out.println(ja.getTitle()+"tittknkgfdx===>") */
List titles = new ArrayList();
for(JournalArticle journalArticle: articles){
titles.add(journalArticle.getTitle());
}
function publishArticle() {
var a = document.getElementById("existingTitles").value;
alert(a);
document.fm1.<%= Constants.CMD %>.value = "<%= Constants.PUBLISH %>";
}