Configure initial page when user clicks on LibrePlan logo depending on roles
Different situations: * If user has ROLE_SUPERUSER: Redirect to "Planning > Company View" * If user has ROLE_BOUND_USER: Redirect to "Personal Area > Home" * If user has ROLE_PLANNING: Redirect to "Planning > Company View" * If user has read or write authorizations over any project: Redirect to "Planning > Company View" * Otherwise: Redirect to "Personal Area > Preferences" FEA: ItEr76S30PermissionsEnhancements
This commit is contained in:
parent
f53c943c07
commit
41ba7fcdcb
4 changed files with 88 additions and 3 deletions
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.libreplan.web.common;
|
||||
|
||||
import org.libreplan.business.users.entities.UserRole;
|
||||
import org.libreplan.web.security.SecurityUtils;
|
||||
import org.libreplan.web.users.services.CustomTargetUrlResolver;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
|
||||
/**
|
||||
* Controller to redirect user to proper initial page depending or roles.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class IndexController extends GenericForwardComposer {
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
||||
String url = getInitialPageURL();
|
||||
Executions.sendRedirect(url);
|
||||
}
|
||||
|
||||
private String getInitialPageURL() {
|
||||
if (SecurityUtils.isUserInRole(UserRole.ROLE_SUPERUSER)) {
|
||||
return CustomTargetUrlResolver.PLANNING_URL;
|
||||
}
|
||||
|
||||
if (SecurityUtils.isUserInRole(UserRole.ROLE_BOUND_USER)) {
|
||||
return CustomTargetUrlResolver.USER_DASHBOARD_URL;
|
||||
}
|
||||
|
||||
if (SecurityUtils.isSuperuserOrRolePlanningOrHasAnyAuthorization()) {
|
||||
return CustomTargetUrlResolver.PLANNING_URL;
|
||||
}
|
||||
|
||||
return CustomTargetUrlResolver.SETTINGS_URL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -47,9 +47,9 @@ public class CustomTargetUrlResolver extends TargetUrlResolverImpl {
|
|||
|
||||
public final static String USER_DASHBOARD_URL = "/myaccount/userDashboard.zul";
|
||||
|
||||
private static final String PLANNING_URL = "/planner/index.zul";
|
||||
public static final String PLANNING_URL = "/planner/index.zul";
|
||||
|
||||
private static final String SETTINGS_URL = "/myaccount/settings.zul";
|
||||
public static final String SETTINGS_URL = "/myaccount/settings.zul";
|
||||
|
||||
@Autowired
|
||||
private IUserDAO userDAO;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@
|
|||
</session-config>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>/planner/index.zul</welcome-file>
|
||||
<welcome-file>/index.zul</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
<error-page>
|
||||
|
|
|
|||
24
libreplan-webapp/src/main/webapp/index.zul
Normal file
24
libreplan-webapp/src/main/webapp/index.zul
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<!--
|
||||
This file is part of LibrePlan
|
||||
|
||||
Copyright (C) 2012 Igalia, S.L.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<zk>
|
||||
|
||||
<window apply="org.libreplan.web.common.IndexController" />
|
||||
|
||||
</zk>
|
||||
Loading…
Add table
Reference in a new issue