Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-2537] Add missing parameters to Ticket entities #352

Merged
merged 2 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class EmailVerificationTicket {
private String ticket;
@JsonProperty("includeEmailInRedirect")
private Boolean includeEmailInRedirect;
@JsonProperty("client_id")
private String clientId;
@JsonProperty("organization_id")
private String organizationId;
@JsonProperty("identity")
private EmailVerificationIdentity identity;

Expand Down Expand Up @@ -72,6 +76,31 @@ public void setIncludeEmailInRedirect(Boolean includeEmailInRedirect) {
this.includeEmailInRedirect = includeEmailInRedirect;
}

/**
* Sets the ID of the client. If provided for tenants using New Universal Login experience, the user will be prompted
* to redirect to the default login route of the corresponding application once the ticket is used.
*
* @param clientId the ID of the client
*
* @see <a href="https://auth0.com/docs/universal-login/configure-default-login-routes#completing-the-password-reset-flow">Configuring Default Login Routes</a>
*/
@JsonProperty("client_id")
public void setClientId(String clientId) {
this.clientId = clientId;
}

/**
* Sets the ID of the Organization. If provided, organization parameters will be made available to the email template
* and organization branding will be applied to the prompt. In addition, the redirect link in the prompt will include
* {@code organization_id} and {@code organization_name} query string parameters.
*
* @param organizationId the ID of the organization
*/
@JsonProperty("organization_id")
public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}

/**
* Sets the identity. Needed to verify primary identities when using social, enterprise, or passwordless connections.
* It is also required to verify secondary identities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class PasswordChangeTicket {
private Boolean markEmailAsVerified;
@JsonProperty("organization_id")
private String orgId;
@JsonProperty("client_id")
private String clientId;
@JsonProperty("includeEmailInRedirect")
private Boolean includeEmailInRedirect;

@JsonCreator
public PasswordChangeTicket(@JsonProperty("user_id") String userId) {
Expand All @@ -44,7 +48,7 @@ public PasswordChangeTicket(String email, String connectionId) {
}

/**
* Setter for the id of the user this ticket is meant to.
* Setter for the id of the user for whom the ticket should be created.
*
* @param userId the user id to set.
*/
Expand All @@ -53,6 +57,18 @@ public void setUserId(String userId) {
this.userId = userId;
}

/**
* Setter for the client_id
* @param clientId the ID of the client to set
*/
public void setClientId(String clientId) {
this.clientId = clientId;
}

public void setIncludeEmailInRedirect(Boolean includeEmailInRedirect) {
this.includeEmailInRedirect = includeEmailInRedirect;
}

/**
* Setter for the url the user will be redirected to after using the ticket.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ public void shouldSerialize() throws Exception {
ticket.setResultUrl("https://page.auth0.com/result");
ticket.setTTLSeconds(36000);
ticket.setIncludeEmailInRedirect(true);
ticket.setClientId("client_abc");
ticket.setOrganizationId("org_abc");

String serialized = toJSON(ticket);
assertThat(serialized, is(notNullValue()));
assertThat(serialized, JsonMatcher.hasEntry("user_id", "usr123"));
assertThat(serialized, JsonMatcher.hasEntry("result_url", "https://page.auth0.com/result"));
assertThat(serialized, JsonMatcher.hasEntry("ttl_sec", 36000));
assertThat(serialized, JsonMatcher.hasEntry("includeEmailInRedirect", true));
assertThat(serialized, JsonMatcher.hasEntry("client_id", "client_abc"));
assertThat(serialized, JsonMatcher.hasEntry("organization_id", "org_abc"));
}

@Test
Expand Down Expand Up @@ -59,4 +63,4 @@ public void shouldIncludeReadOnlyValuesOnDeserialize() throws Exception {
assertThat(ticket.getTicket(), is("https://page.auth0.com/tickets/123"));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public void shouldSerialize() throws Exception {
ticket.setNewPassword("pass123");
ticket.setMarkEmailAsVerified(true);
ticket.setOrganizationId("org_abc");
ticket.setClientId("client_abc");
ticket.setIncludeEmailInRedirect(false);

String serialized = toJSON(ticket);
assertThat(serialized, is(notNullValue()));
Expand All @@ -34,6 +36,8 @@ public void shouldSerialize() throws Exception {
assertThat(serialized, JsonMatcher.hasEntry("email", "me@auth0.com"));
assertThat(serialized, JsonMatcher.hasEntry("mark_email_as_verified", true));
assertThat(serialized, JsonMatcher.hasEntry("organization_id", "org_abc"));
assertThat(serialized, JsonMatcher.hasEntry("client_id", "client_abc"));
assertThat(serialized, JsonMatcher.hasEntry("includeEmailInRedirect", false));
}

@SuppressWarnings("deprecation")
Expand Down