Hello,
I want to add to the execute action email the redirectUri (the executeActionEmail get the redirectUri but don’t pass it as attribute to the html)
What I did is to override:
http://localhost:8080/admin/realms/[REALM_NAME]/users/[USERS_ID]/execute-actions-email?redirect_uri=redirect_uri&client_id=client_id
- create CustomUserResource which extend UserResource and override the execute action method (adding the redirectUri as attribute)
- create CustomUsersResource which extend UsersResource and override getUserResource to return my CustomUserResource
- implement AdminRealmResourceProvider and AdminRealmResourceProviderFactory to create CustomUsersResource
But when calling the executeActions it didn’t use my code.
When calling http://localhost:8080/admin/realms/[REALM_NAME]/[MY-SPI_ID]/[USERS_ID]/execute-actions-email?redirect_uri=redirect_uri&client_id=client_id
when using the providerId in the path it used my code, but I want the original path.
I try changing my provider id to be = “users” and give him order 1, but still it didn’t use my code.
Is there something I missing for override the exist end point? is it possible?
xgp
2
You can’t “override” built-in REST resources. You can build your own and call that.
If you just want to change what is passed to your email templates, you can implement a custom EmailTemplateProvider
- Is it document somewhere that it’s impossible to override the build it endpoint?
- This is the code in UserResource which execute the email:
public Response executeActionsEmail(@Parameter(description = "Redirect uri") @QueryParam(OIDCLoginProtocol.REDIRECT_URI_PARAM) String redirectUri,
@Parameter(description = "Client id") @QueryParam(OIDCLoginProtocol.CLIENT_ID_PARAM) String clientId,
@Parameter(description = "Number of seconds after which the generated token expires") @QueryParam("lifespan") Integer lifespan,
@Parameter(description = "Required actions the user needs to complete") List<String> actions)
// some verifications
this.session.getProvider(EmailTemplateProvider.class)
.setAttribute(Constants.TEMPLATE_ATTR_REQUIRED_ACTIONS, token.getRequiredActions())
.setRealm(realm)
.setUser(user)
.sendExecuteActions(link, TimeUnit.SECONDS.toMinutes(lifespan));
How having custom EmailTemplateProvider will help? how this code will send to the EmailTemplateProvider the redirectUri?