Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #104 from zanata/fix_dashboard_redirection
Browse files Browse the repository at this point in the history
Implement redirect to dashboard after login
  • Loading branch information
carlosmunoz committed Aug 8, 2013
2 parents bc14ea9 + 63f0373 commit b4ed242
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 38 deletions.
Expand Up @@ -230,7 +230,8 @@ public void openIdAuthenticate(OpenIdProviderType openIdProviderType, String use
* aimed for.<br/>
* home - Redirect the user to the home page.<br/>
* inactive - The user's account is inactive.<br/>
* login - Redirect the user to the login page.
* login - Redirect the user to the login page.<br/>
* dashboard - Redirect the user to dashboard page.
*/
public String getAuthenticationRedirect()
{
Expand All @@ -246,9 +247,12 @@ else if(identity.isPreAuthenticated() && isNewUser())
}
else if (identity.isLoggedIn())
{
if (userRedirect != null && userRedirect.isRedirect())
if (userRedirect != null)
{
return "redirect";
if(userRedirect.isRedirect() && !userRedirect.isRedirectToHome())
{
return "redirect";
}
}
return "dashboard";
}
Expand Down
21 changes: 15 additions & 6 deletions zanata-war/src/main/java/org/zanata/security/UserRedirectBean.java
Expand Up @@ -52,7 +52,6 @@ public class UserRedirectBean implements Serializable
{
private static final String HOME_URL = "/";
private static final String ERROR_URL = "/error";
private static final String DASHBOARD_HOME_URL = "/dashboard/home.xhtml";

/**
*
Expand Down Expand Up @@ -177,13 +176,23 @@ public boolean isRedirect()
return url != null && !url.isEmpty();
}

public void redirectToDashboard()
public boolean isRedirectToHome()
{
if (Identity.instance().isLoggedIn())
if (isRedirect())
{
Redirect redirect = Redirect.instance();
redirect.setViewId(DASHBOARD_HOME_URL);
redirect.execute();
String url = getUrl();
int qsIndex = url.indexOf('?');
if (qsIndex > 0)
{
url = url.substring(0, qsIndex);
}

if (url.endsWith(HOME_URL))
{
return true;
}

}
return false;
}
}
53 changes: 25 additions & 28 deletions zanata-war/src/main/webapp/WEB-INF/pages.xml
Expand Up @@ -12,31 +12,6 @@
</navigation>
</page>

<page view-id="/home.xhtml">
<action execute="#{userRedirect.redirectToDashboard}"/>
</page>

<!-- Landing page for open id authentication -->
<page view-id="/openid.xhtml">
<navigation>
<rule if="#{authenticationManager.authenticated and authenticationManager.newUser}">
<redirect view-id="/profile/edit.xhtml" />
</rule>
<rule if="#{!identity.isLoggedIn() and authenticationManager.authenticatedAccountWaitingForActivation}">
<redirect view-id="/account/inactive_account.xhtml"/>
</rule>
<rule if="#{!identity.loggedIn}">
<redirect view-id="/account/login_input.xhtml" />
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and !userRedirect.redirect}">
<redirect view-id="/dashboard/home.xhtml" />
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and userRedirect.redirect}">
<redirect url="#{userRedirect.url}" />
</rule>
</navigation>
</page>

<page view-id="/edit_home_content.xhtml">
<action execute="#{breadcrumbs.clear}"/>
<action execute="#{breadcrumbs.addLocation('', messages['jsf.server.EditHomePage.label'])}"/>
Expand All @@ -61,8 +36,30 @@
<redirect view-id="/search.xhtml"/>
</navigation>
</page>

<!-- Landing page for open id authentication -->
<page view-id="/openid.xhtml">
<navigation>
<rule if="#{authenticationManager.authenticated and authenticationManager.newUser}">
<redirect view-id="/profile/edit.xhtml" />
</rule>
<rule if="#{!identity.isLoggedIn() and authenticationManager.authenticatedAccountWaitingForActivation}">
<redirect view-id="/account/inactive_account.xhtml"/>
</rule>
<rule if="#{!identity.loggedIn}">
<redirect view-id="/account/login_input.xhtml" />
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and userRedirect.redirectToHome}">
<redirect view-id="/dashboard/home.xhtml" />
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and userRedirect.redirect}">
<redirect url="#{userRedirect.url}" />
</rule>
</navigation>
</page>


<!-- Kerberos Authentication -->
<!-- Landing page for Kerberos Authentication -->
<page view-id="/account/klogin.xhtml">
<header name="Cache-Control" value="no-cache, no-store, max-age=0, must-revalidate" />
<param name="continue" value="#{userRedirect.encodedUrl}" />
Expand Down Expand Up @@ -90,7 +87,7 @@
</navigation>
</page>

<!-- Internal and JAAS authentication -->
<!-- Landing page for Internal and JAAS authentication -->
<page view-id="/account/login_input.xhtml">
<header name="Cache-Control" value="no-cache, no-store, max-age=0, must-revalidate" />
<param name="continue" value="#{userRedirect.encodedUrl}" />
Expand All @@ -104,7 +101,7 @@
<begin-conversation/>
<redirect view-id="/account/inactive_account.xhtml"/>
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and !userRedirect.redirect}">
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and userRedirect.redirectToHome}">
<redirect view-id="/dashboard/home.xhtml" />
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and userRedirect.redirect}">
Expand Down
5 changes: 5 additions & 0 deletions zanata-war/src/main/webapp/WEB-INF/template/banner.xhtml
Expand Up @@ -48,6 +48,11 @@

<nav id="nav-main" class="header__menu is-hidden--s l--push-left-half">
<ul class="list--horizontal">
<s:fragment rendered="#{identity.loggedIn}">
<li class="l--push-left-half">
<s:link id="dashboard_link" view="/dashboard/home.xhtml" propagation="none">#{messages['jsf.Dashboard']}</s:link>
</li>
</s:fragment>
<li class="l--push-left-half">
<s:link id="projects_link" view="/project/home.xhtml" propagation="none">#{messages['jsf.Projects']}</s:link>
</li>
Expand Down
12 changes: 11 additions & 1 deletion zanata-war/src/main/webapp/WEB-INF/template/left_menu.xhtml
Expand Up @@ -15,13 +15,23 @@
</header>
<nav id="nav-main-side">
<ul class="list--slat list--block-links">

<s:fragment rendered="#{identity.loggedIn}">
<li>
<s:link id="left_menu_dashboard_link" view="/dashboard/home.xhtml" propagation="none">
#{messages['jsf.Dashboard']}
</s:link>
</li>
</s:fragment>
<li><s:link id="left_menu_projects_link" view="/project/home.xhtml" propagation="none">#{messages['jsf.Projects']}</s:link></li>
<li><s:link id="left_menu_version-groups_link" view="/version-group/home.xhtml" propagation="none">#{messages['jsf.Groups']}</s:link></li>
<li><s:link id="left_menu_languages_link" view="/language/home.xhtml" propagation="none">#{messages['jsf.Languages']}</s:link></li>

<s:fragment rendered="#{identity.loggedIn}">
<li>
<s:link id="left_menu_glossary_link" view="/glossary/view.xhtml" propagation="none">#{messages['jsf.Glossary']}</s:link>
<s:link id="left_menu_glossary_link" view="/glossary/view.xhtml" propagation="none">
#{messages['jsf.Glossary']}
</s:link>
</li>
</s:fragment>

Expand Down

0 comments on commit b4ed242

Please sign in to comment.