cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the landing page after login

prashidhashrest
Confirmed Champ
Confirmed Champ

Hello,

I am trying to get the user that successfully login directly into my site dashboard home page. For that I have changed the site-index.jsp but it keeps on taking it back to default dashboard.

Here is my code below.

<%--
#%L
Alfresco Share WAR
%%
Copyright (C) 2005 - 2016 Alfresco Software Limited
%%
This file is part of the Alfresco software.
If the software was purchased under a paid Alfresco license, the terms of
the paid license agreement will prevail. Otherwise, the software is
provided under the following open source license terms:

Alfresco is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Alfresco 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
#L%
--%>
<%@ page import="org.alfresco.web.site.*" %>
<%@ page import="org.springframework.extensions.surf.*" %>
<%@ page import="org.springframework.extensions.surf.site.*" %>
<%@ page import="org.springframework.extensions.surf.util.*" %>
<%@ page import="java.util.*" %>
<%
// retrieve user name from the session
String userid = (String)session.getAttribute(SlingshotUserFactory.SESSION_ATTRIBUTE_KEY_USER_ID);

// test user dashboard page exists?
RequestContext context = (RequestContext)request.getAttribute(RequestContext.ATTR_REQUEST_CONTEXT);
if (!context.getObjectService().hasPage("user/" + userid + "/dashboard"))
{
// no user dashboard page found! create initial dashboard for this user...
Map<String, String> tokens = new HashMap<String, String>();
tokens.put("userid", userid);
FrameworkUtil.getServiceRegistry().getPresetsManager().constructPreset("user-dashboard", tokens);
}

// redirect to site or user dashboard as appropriate
String siteName = request.getParameter("mysite");
if (siteName == null || siteName.length() == 0)
{
// Get and forward to user's home page
SlingshotUserFactory slingshotUserFactory =
(SlingshotUserFactory) FrameworkUtil.getServiceRegistry().getUserFactory();
String userHomePage = slingshotUserFactory.getUserHomePage(context, userid);
response.sendRedirect(request.getContextPath() + userHomePage);
}
else
{
// forward to site specific dashboard page
response.sendRedirect(request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName) + "/dashboard");
}
%>

mysite is the name of my site.

Only change I have made is the site name on first bold line and another on the second bold line where I added +"/dashboard".

Any idea where I am going wrong.

Thanks in advance

1 ACCEPTED ANSWER

douglascrp
World-Class Innovator
World-Class Innovator

You say "mySite" is the name of my site.

If that is the case, why are you reading the name of the site from the parameters?

String siteName = request.getParameter("mysite");

If I understood it correctly, that line of code could be changed to something like

String siteName = "mysite";

View answer in original post

3 REPLIES 3

cesarista
World-Class Innovator
World-Class Innovator

What is your Alfresco version ? From recent Alfresco 5.2 versions, users have redirect login page feature.

Kind regards.

--C.

The Alfresco version is Alfresco Community v5.2.0.

douglascrp
World-Class Innovator
World-Class Innovator

You say "mySite" is the name of my site.

If that is the case, why are you reading the name of the site from the parameters?

String siteName = request.getParameter("mysite");

If I understood it correctly, that line of code could be changed to something like

String siteName = "mysite";