mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-09 23:12:06 -03:30
Organization invite link leads to non-defined page, when clicked second time
Closes #36569 Signed-off-by: Martin Kanis <mkanis@redhat.com>
This commit is contained in:
parent
2dd5e7a7f5
commit
add0d69b89
@ -37,7 +37,6 @@ import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.organization.OrganizationProvider;
|
||||
import org.keycloak.protocol.oidc.OIDCLoginProtocol;
|
||||
import org.keycloak.protocol.oidc.utils.RedirectUtils;
|
||||
import org.keycloak.services.Urls;
|
||||
import org.keycloak.services.managers.AuthenticationManager;
|
||||
import org.keycloak.services.messages.Messages;
|
||||
@ -117,6 +116,7 @@ public class InviteOrgActionTokenHandler extends AbstractActionTokenHandler<Invi
|
||||
return session.getProvider(LoginFormsProvider.class)
|
||||
.setAuthenticationSession(authSession)
|
||||
.setInfo(Messages.ORG_MEMBER_ALREADY, user.getUsername())
|
||||
.setAttribute("pageRedirectUri", organization.getRedirectUrl())
|
||||
.createInfoPage();
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.keycloak.services.messages.Messages.ORG_MEMBER_ALREADY;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -111,6 +112,31 @@ public class OrganizationInvitationLinkTest extends AbstractOrganizationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRedirectAfterClickingSecondTimeOnInvitation() throws IOException, MessagingException {
|
||||
UserRepresentation user = createUser("invited", "invited@myemail.com");
|
||||
|
||||
OrganizationResource organization = testRealm().organizations().get(createOrganization().getId());
|
||||
|
||||
try (
|
||||
OrganizationAttributeUpdater oau = new OrganizationAttributeUpdater(organization).setRedirectUrl(OAuthClient.APP_AUTH_ROOT).update();
|
||||
Response response = organization.members().inviteExistingUser(user.getId());
|
||||
) {
|
||||
assertThat(response.getStatus(), equalTo(Response.Status.NO_CONTENT.getStatusCode()));
|
||||
|
||||
acceptInvitation(organization, user, "AUTH_RESPONSE");
|
||||
|
||||
String link = getInvitationLinkFromEmail(user.getFirstName(), user.getLastName());
|
||||
driver.navigate().to(link);
|
||||
|
||||
assertThat(driver.getPageSource(), containsString(ORG_MEMBER_ALREADY));
|
||||
|
||||
infoPage.clickBackToApplicationLink();
|
||||
// redirect to the redirectUrl of the organization
|
||||
assertThat(driver.getTitle(), containsString("AUTH_RESPONSE"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInviteExistingUserWithEmail() throws IOException, MessagingException {
|
||||
UserRepresentation user = createUser("invitedWithMatchingEmail", "invitedWithMatchingEmail@myemail.com");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user