From 66a4e60b163cff7297a6aa099e7b26179a061bab Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 22 Feb 2018 17:53:09 +0530 Subject: [PATCH] Enable user's last name in the email template This is to enable the user's last name also to be included in the meta information list on email templates. When customizing the email template users can define to include both fist and last name to the content or title of the email --- .../mgt/jaxrs/service/impl/UserManagementServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index 25794c833b0..053d09f77c5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -151,6 +151,7 @@ public class UserManagementServiceImpl implements UserManagementService { String recipient = userInfo.getEmailAddress(); Properties props = new Properties(); props.setProperty("first-name", userInfo.getFirstname()); + props.setProperty("last-name", userInfo.getLastname()); props.setProperty("username", username); props.setProperty("password", initialUserPassword); @@ -609,10 +610,15 @@ public class UserManagementServiceImpl implements UserManagementService { Properties props = new Properties(); String username = DeviceMgtAPIUtils.getAuthenticatedUser(); String firstName = getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME); + String lastName = getClaimValue(username, Constants.USER_CLAIM_LAST_NAME); if (firstName == null) { firstName = username; } + if (lastName == null) { + lastName = ""; + } props.setProperty("first-name", firstName); + props.setProperty("last-name", lastName); props.setProperty("device-type", enrollmentInvitation.getDeviceType()); EmailMetaInfo metaInfo = new EmailMetaInfo(recipients, props); dms.sendEnrolmentInvitation(getEnrollmentTemplateName(enrollmentInvitation.getDeviceType()), metaInfo);