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

Fix redirect to login page when using single open id provider authentication #579

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions zanata-war/src/main/java/org/zanata/action/LoginAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.security.Identity;
import org.zanata.ApplicationConfiguration;
import org.zanata.security.AuthenticationManager;
import org.zanata.security.AuthenticationType;
Expand All @@ -50,6 +51,9 @@
public class LoginAction implements Serializable {
private static final long serialVersionUID = 1L;

@In
private Identity identity;

@In
private ZanataCredentials credentials;

Expand Down Expand Up @@ -151,4 +155,24 @@ public static OpenIdProviderType getBestSuitedProvider(String openId) {
return OpenIdProviderType.Generic;
}
}

/**
* Indicates which location a user should be redirected when accessing the
* login page.
*
* @return A string indicating where the user should be redirected when
* trying to access the login page.
*/
public String getLoginPageRedirect() {
if (identity.isLoggedIn()) {
return "dashboard";
}
if (applicationConfiguration.isOpenIdAuth()
&& applicationConfiguration.isSingleOpenIdProvider()) {
// go directly to the provider's login page
return genericOpenIdLogin(applicationConfiguration
.getOpenIdProviderUrl());
}
return "login";
}
}
6 changes: 3 additions & 3 deletions zanata-war/src/main/webapp/WEB-INF/pages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@
value="no-cache, no-store, max-age=0, must-revalidate" />
<param name="continue" value="#{userRedirect.encodedUrl}" />

<action execute="#{identity.isLoggedIn()}" />
<navigation from-action="#{identity.isLoggedIn()}">
<rule if-outcome="true">
<action execute="#{loginAction.getLoginPageRedirect()}" />
<navigation from-action="#{loginAction.getLoginPageRedirect()}">
<rule if-outcome="dashboard">
<redirect view-id="/dashboard/home.xhtml" />
</rule>
</navigation>
Expand Down
2 changes: 1 addition & 1 deletion zanata-war/src/main/webapp/WEB-INF/template/banner.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@

<h:form rendered="#{applicationConfigurationAction.singleOpenId}">
<h:commandLink id="openid_single_signin_link"
action="#{loginAction.genericOpenIdLogin(applicationConfiguration.openIdProviderUrl)}"
action="#{loginAction.getLoginPageRedirect()}"
propagation="none" styleClass="l--push-left-half button--primary">
#{messages['jsf.Login']}
</h:commandLink>
Expand Down