-
Notifications
You must be signed in to change notification settings - Fork 57
Fix redirect to login page when using single open id provider authentication #579
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -50,6 +51,9 @@ | |
public class LoginAction implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@In | ||
private Identity identity; | ||
|
||
@In | ||
private ZanataCredentials credentials; | ||
|
||
|
@@ -151,4 +155,26 @@ public static OpenIdProviderType getBestSuitedProvider(String openId) { | |
return OpenIdProviderType.Generic; | ||
} | ||
} | ||
|
||
/** | ||
* This method is executed when accessing the login page. Depending on | ||
* current session state, it might indicate to redirect to a different | ||
* location. For example, if the user is already logged in, it will indicate | ||
* to redirect to the dashboard. | ||
* | ||
* @return A string indicating where the user should be redirected when | ||
* trying to access the login page. | ||
*/ | ||
public String onLoginPageAccessed() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name makes this look like an event handler, which suggests that it would perform some action, but all it does is return a String. Its purpose is to provide an identifier for which page to redirect to, so why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like that because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (identity.isLoggedIn()) { | ||
return "dashboard"; | ||
} | ||
if (applicationConfiguration.isOpenIdAuth() | ||
&& applicationConfiguration.isSingleOpenIdProvider()) { | ||
// go directly to the provider's login page | ||
return genericOpenIdLogin(applicationConfiguration | ||
.getOpenIdProviderUrl()); | ||
} | ||
return "login"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,7 @@ | |
|
||
<h:form rendered="#{applicationConfigurationAction.singleOpenId}"> | ||
<h:commandLink id="openid_single_signin_link" | ||
action="#{loginAction.genericOpenIdLogin(applicationConfiguration.openIdProviderUrl)}" | ||
action="#{loginAction.goToLoginPage()}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this was missed when renaming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, good catch. |
||
propagation="none" styleClass="l--push-left-half button--primary"> | ||
#{messages['jsf.Login']} | ||
</h:commandLink> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first line should give a reasonable summary, before giving all the details. e.g.