Merge pull request #2165 from stianst/master

KEYCLOAK-2435
This commit is contained in:
Stian Thorgersen 2016-02-03 14:54:42 +01:00
commit 337f390090
13 changed files with 31 additions and 22 deletions

View file

@ -109,6 +109,8 @@ public interface LoginFormsProvider extends Provider {
public LoginFormsProvider setSuccess(String message, Object ... parameters);
public LoginFormsProvider setInfo(String message, Object ... parameters);
public LoginFormsProvider setUser(UserModel user);
public LoginFormsProvider setResponseHeader(String headerName, String headerValue);

View file

@ -67,6 +67,6 @@ public class IdpUsernamePasswordForm extends UsernamePasswordForm {
return context.form()
.setFormData(formData)
.setAttribute(LoginFormsProvider.USERNAME_EDIT_DISABLED, true)
.setSuccess(Messages.FEDERATED_IDENTITY_CONFIRM_REAUTHENTICATE_MESSAGE, existingUser.getUsername(), serializedCtx.getIdentityProviderId());
.setInfo(Messages.FEDERATED_IDENTITY_CONFIRM_REAUTHENTICATE_MESSAGE, existingUser.getUsername(), serializedCtx.getIdentityProviderId());
}
}

View file

@ -569,6 +569,12 @@ public class FreeMarkerLoginFormsProvider implements LoginFormsProvider {
return this;
}
@Override
public FreeMarkerLoginFormsProvider setInfo(String message, Object... parameters) {
setMessage(MessageType.INFO, message, parameters);
return this;
}
@Override
public FreeMarkerLoginFormsProvider setUser(UserModel user) {
this.user = user;

View file

@ -23,6 +23,6 @@ package org.keycloak.theme.beans;
*/
public enum MessageType {
SUCCESS, WARNING, ERROR
SUCCESS, WARNING, INFO, ERROR
}

View file

@ -321,7 +321,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractIdentityProvi
Assert.assertEquals("pedroigor", this.loginPage.getUsername());
Assert.assertFalse(this.loginPage.isUsernameInputEnabled());
Assert.assertEquals("Authenticate as pedroigor to link your account with " + getProviderId(), this.loginPage.getSuccessMessage());
Assert.assertEquals("Authenticate as pedroigor to link your account with " + getProviderId(), this.loginPage.getInfoMessage());
try {
this.loginPage.findSocialButton(getProviderId());

View file

@ -116,7 +116,7 @@ public class OIDCFirstBrokerLoginTest extends AbstractFirstBrokerLoginTest {
// assert reauthentication with login page. On login page is link to kc-saml-idp-basic as user has it linked already
Assert.assertEquals("Log in to " + APP_REALM_ID, this.driver.getTitle());
Assert.assertEquals("Authenticate as pedroigor to link your account with " + getProviderId(), this.loginPage.getSuccessMessage());
Assert.assertEquals("Authenticate as pedroigor to link your account with " + getProviderId(), this.loginPage.getInfoMessage());
try {
this.loginPage.findSocialButton(getProviderId());

View file

@ -265,7 +265,7 @@ public class PostBrokerFlowTest extends AbstractIdentityProviderTest {
// assert reauthentication with login page. On login page is link to kc-saml-idp-basic as user has it linked already
Assert.assertEquals("Log in to " + APP_REALM_ID, this.driver.getTitle());
Assert.assertEquals("Authenticate as test-user to link your account with " + getProviderId(), this.loginPage.getSuccessMessage());
Assert.assertEquals("Authenticate as test-user to link your account with " + getProviderId(), this.loginPage.getInfoMessage());
// reauthenticate with SAML broker. OTP authentication is required as well
this.loginPage.clickSocial("kc-saml-idp-basic");

View file

@ -31,7 +31,7 @@ public class IdpConfirmLinkPage extends AbstractPage {
@FindBy(id = "linkAccount")
private WebElement linkAccountButton;
@FindBy(className = "instruction")
@FindBy(className = "alert-error")
private WebElement message;
@Override

View file

@ -64,7 +64,11 @@ public class LoginPage extends AbstractPage {
private WebElement loginWarningMessage;
@FindBy(className = "alert-success")
private WebElement emailSuccessMessage;
private WebElement loginSuccessMessage;
@FindBy(className = "alert-info")
private WebElement loginInfoMessage;
@FindBy(id = "kc-current-locale-link")
@ -124,7 +128,10 @@ public class LoginPage extends AbstractPage {
}
public String getSuccessMessage() {
return emailSuccessMessage != null ? emailSuccessMessage.getText() : null;
return loginSuccessMessage != null ? loginSuccessMessage.getText() : null;
}
public String getInfoMessage() {
return loginInfoMessage != null ? loginInfoMessage.getText() : null;
}

View file

@ -1,21 +1,13 @@
<#import "template.ftl" as layout>
<@layout.registrationLayout displayMessage=false; section>
<@layout.registrationLayout; section>
<#if section = "title">
${msg("confirmLinkIdpTitle")}
<#elseif section = "header">
${msg("confirmLinkIdpTitle")}
<#elseif section = "form">
<div id="kc-error-message">
<p class="instruction">${message.summary}</p>
</div>
<form id="kc-register-form" class="${properties.kcFormClass!}" action="${url.loginAction}" method="post">
<div id="kc-form-buttons" class="${properties.kcFormGroupClass!}">
<button type="submit" class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonLargeClass!}" name="submitAction" id="updateProfile" value="updateProfile">${msg("confirmLinkIdpReviewProfile")}</button>
<button type="submit" class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonLargeClass!}" name="submitAction" id="linkAccount" value="linkAccount">${msg("confirmLinkIdpContinue", idpAlias)}</button>
</div>
<button type="submit" class="${properties.kcButtonClass!} ${properties.kcButtonDefaultClass!} ${properties.kcButtonLargeClass!}" name="submitAction" id="updateProfile" value="updateProfile">${msg("confirmLinkIdpReviewProfile")}</button>
<button type="submit" class="${properties.kcButtonClass!} ${properties.kcButtonDefaultClass!} ${properties.kcButtonLargeClass!}" name="submitAction" id="linkAccount" value="linkAccount">${msg("confirmLinkIdpContinue", idpAlias)}</button>
</form>
</#if>
</@layout.registrationLayout>

View file

@ -143,8 +143,8 @@ federatedIdentityExistsMessage=User with {0} {1} already exists. Please login to
confirmLinkIdpTitle=Account already exists
federatedIdentityConfirmLinkMessage=User with {0} {1} already exists. How do you want to continue?
federatedIdentityConfirmReauthenticateMessage=Authenticate as {0} to link your account with {1}
confirmLinkIdpReviewProfile=Review profile info
confirmLinkIdpContinue=Link {0} with existing account
confirmLinkIdpReviewProfile=Review profile
confirmLinkIdpContinue=Add to existing account
configureTotpMessage=You need to set up Mobile Authenticator to activate your account.
updateProfileMessage=You need to update your user profile to activate your account.

View file

@ -62,6 +62,7 @@
<#if message.type = 'success'><span class="${properties.kcFeedbackSuccessIcon}"></span></#if>
<#if message.type = 'warning'><span class="${properties.kcFeedbackWarningIcon}"></span></#if>
<#if message.type = 'error'><span class="${properties.kcFeedbackErrorIcon}"></span></#if>
<#if message.type = 'info'><span class="${properties.kcFeedbackInfoIcon}"></span></#if>
<span class="kc-feedback-text">${message.summary}</span>
</div>
</div>

View file

@ -20,7 +20,8 @@ kcFormAreaClass=col-xs-12 col-sm-8 col-md-8 col-lg-7 login
kcFeedbackErrorIcon=pficon pficon-error-circle-o
kcFeedbackWarningIcon=pficon pficon-warning-triangle-o
kcFeedbackSuccessIcon=alert alert-success
kcFeedbackSuccessIcon=pficon pficon-ok
kcFeedbackInfoIcon=pficon pficon-info
kcFormClass=form-horizontal