Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Commit 6fb1b16

Browse files
committed
added missing configuration
1 parent 2518805 commit 6fb1b16

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

src/main/java/com/appirio/tech/core/service/identity/IdentityApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public void run(IdentityConfiguration configuration, Environment environment) th
233233
UserResource userResource = new UserResource(userDao, roleDao, cacheService, eventProducer, eventBusServiceClient, configuration.getM2mAuthConfiguration().getUserProfiles());
234234
userResource.setAuth0Client(configuration.getAuth0()); // TODO: constructor
235235
userResource.setDomain(configuration.getAuthDomain());
236+
userResource.setSendgridTemplateId(configuration.getContext().get("sendGridTemplateId"));
236237
// this secret _used_ to be different from the one used in AuthorizationResource.
237238
// it _was_ the secret x2. (userResource.setSecret(getSecret()+getSecret());)
238239
// we assume this was done to further limit the usability of the oneTimeToken generated in userResource

src/main/java/com/appirio/tech/core/service/identity/resource/UserResource.java

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public class UserResource implements GetResource<User>, DDLResource<User> {
102102
private int oneTimeTokenExpirySeconds = 10 * 60; //10min
103103

104104
private String domain;
105+
106+
private String sendgridTemplateId;
105107

106108
protected UserDAO userDao;
107109

@@ -891,29 +893,32 @@ public ApiResponse resendEmail(
891893
throw new APIRuntimeException(SC_UNAUTHORIZED, "Credentials are incorrect.");
892894
}
893895

894-
//user.setRoles(roles);
895-
if(!user.isActive()) {
896-
EventMessage msg = EventMessage.getDefault();
897-
msg.setTopic("identity.action.email.resend");
896+
// return 400 if user has been activated
897+
if(user.isActive())
898+
throw new APIRuntimeException(SC_BAD_REQUEST, MSG_TEMPLATE_USER_ALREADY_ACTIVATED);
898899

899-
Map<String,Object> payload = new LinkedHashMap<String,Object>();
900+
EventMessage msg = EventMessage.getDefault();
901+
msg.setTopic("external.action.email");
900902

901-
Map<String,Object> data = new LinkedHashMap<String,Object>();
902-
data.put("handle", user.getHandle());
903-
data.put("code", user.getCredential().getActivationCode());
903+
Map<String,Object> payload = new LinkedHashMap<String,Object>();
904904

905-
payload.put("data", data);
906-
payload.put("version", "v3");
907-
payload.put("sendgrid_template_id", "ddd");
905+
Map<String,Object> data = new LinkedHashMap<String,Object>();
906+
data.put("handle", user.getHandle());
907+
data.put("code", user.getCredential().getActivationCode());
908+
data.put("domain", getDomain());
908909

909-
ArrayList<String> recipients = new ArrayList<String>();
910-
recipients.add(user.getEmail());
910+
payload.put("data", data);
911+
payload.put("version", "v3");
912+
payload.put("sendgrid_template_id", this.getSendgridTemplateId());
911913

912-
payload.put("recipients", recipients);
914+
ArrayList<String> recipients = new ArrayList<String>();
915+
recipients.add(user.getEmail());
916+
917+
payload.put("recipients", recipients);
918+
919+
msg.setPayload(payload);
920+
this.eventBusServiceClient.reFireEvent(msg);
913921

914-
msg.setPayload(payload);
915-
this.eventBusServiceClient.reFireEvent(msg);
916-
}
917922
return ApiResponseFactory.createResponse(user);
918923
}
919924

@@ -1721,6 +1726,14 @@ public void setDomain(String domain) {
17211726
this.domain = domain;
17221727
}
17231728

1729+
public String getSendgridTemplateId() {
1730+
return sendgridTemplateId;
1731+
}
1732+
1733+
public void setSendgridTemplateId(String sendgridTemplateId) {
1734+
this.sendgridTemplateId = sendgridTemplateId;
1735+
}
1736+
17241737
public String getSecret() {
17251738
return secret;
17261739
}

src/main/resources/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ context:
1111
defaultPassword: @application.password.default@
1212
passwordHashKey: @application.password.key@
1313
ssoTokenSalt: @application.ssotoken.salt@
14+
sendGridTemplateId: @application.sendgrid.template.id@
1415
jwtExpirySeconds: 600
1516
cookieExpirySeconds: 7776000
1617

0 commit comments

Comments
 (0)