diff --git a/keycloak_client.go b/keycloak_client.go index 989b3b3..ff35914 100644 --- a/keycloak_client.go +++ b/keycloak_client.go @@ -386,19 +386,18 @@ func str(s string) *string { return &s } - // Token is JWT token. // We need to define our own structure as the library define aud as a string but it can also be a string array. // To fix this issue, we remove aud as we do not use it here. type Token struct { hdr *header - Issuer string `json:"iss,omitempty"` - Subject string `json:"sub,omitempty"` - ExpirationTime int64 `json:"exp,omitempty"` - NotBefore int64 `json:"nbf,omitempty"` - IssuedAt int64 `json:"iat,omitempty"` - ID string `json:"jti,omitempty"` - Username string `json:"preferred_username,omitempty"` + Issuer string `json:"iss,omitempty"` + Subject string `json:"sub,omitempty"` + ExpirationTime int64 `json:"exp,omitempty"` + NotBefore int64 `json:"nbf,omitempty"` + IssuedAt int64 `json:"iat,omitempty"` + ID string `json:"jti,omitempty"` + Username string `json:"preferred_username,omitempty"` } type header struct { @@ -407,4 +406,3 @@ type header struct { Type string `json:"typ,omitempty"` ContentType string `json:"cty,omitempty"` } - diff --git a/users.go b/users.go index 761a36e..78bdac2 100644 --- a/users.go +++ b/users.go @@ -16,6 +16,7 @@ const ( resetPasswordPath = userIDPath + "/reset-password" sendVerifyEmailPath = userIDPath + "/send-verify-email" executeActionsEmailPath = userIDPath + "/execute-actions-email" + sendReminderEmailPath = "/auth/realms/:realm/onboarding/sendReminderEmail" smsAPI = "/auth/realms/:realm/smsApi" sendNewEnrolmentCode = smsAPI + "/sendNewCode" getCredentialsForUserPath = usersAdminExtensionApiPath + "/:id/credentials" @@ -113,6 +114,19 @@ func (c *Client) SendNewEnrolmentCode(accessToken string, realmName string, user return resp, err } +// SendReminderEmail sends a reminder email to a user +func (c *Client) SendReminderEmail(accessToken string, realmName string, userID string, paramKV ...string) error { + if len(paramKV)%2 != 0 { + return fmt.Errorf("the number of key/val parameters should be even") + } + var newParamKV = append(paramKV, "userid", userID) + + var plugins = append(createQueryPlugins(newParamKV...), url.Path(sendReminderEmailPath), url.Param("realm", realmName)) + + _, err := c.post(accessToken, nil, plugins...) + return err +} + // GetCredentialsForUser gets the credential list for a user func (c *Client) GetCredentialsForUser(accessToken string, realmReq, realmName string, userID string) ([]CredentialRepresentation, error) { var resp = []CredentialRepresentation{}