diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/OTPManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/OTPManagementService.java index 8ecb4de4fd..f63a95ca32 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/OTPManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/OTPManagementService.java @@ -24,6 +24,8 @@ import org.wso2.carbon.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitati import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; import org.wso2.carbon.device.mgt.common.otp.mgt.wrapper.OTPWrapper; +import java.util.Map; + public interface OTPManagementService { /** @@ -44,11 +46,14 @@ public interface OTPManagementService { OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException; /** - * Invalidate the OTP + * Invalidate the OTP and send welcome mail * @param oneTimeToken OTP - * @throws OTPManagementException If error occurred while invalidating the OTP + * @param email email address + * @param properties email properties to add to email body + * @throws OTPManagementException if error occurred while invalidate the OTP or send welcome email */ - void invalidateOTP(String oneTimeToken) throws OTPManagementException; + void completeSelfRegistration(String oneTimeToken, String email, Map properties) + throws OTPManagementException; /** * Create OTP token and send device enrollment invitation diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java index ee7db06f15..111f9e3591 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java @@ -58,6 +58,7 @@ import static org.wso2.carbon.device.mgt.common.DeviceManagementConstants.OTPPro import java.sql.Timestamp; import java.util.Calendar; import java.util.List; +import java.util.Map; import java.util.Properties; import java.util.UUID; @@ -150,7 +151,26 @@ public class OTPManagementServiceImpl implements OTPManagementService { } @Override - public void invalidateOTP(String oneTimeToken) throws OTPManagementException { + public void completeSelfRegistration(String oneTimeToken, String email, Map properties) + throws OTPManagementException { + try { + invalidateOTP(oneTimeToken); + Properties props = new Properties(); + properties.forEach(props::setProperty); + sendMail(props, email); + } catch (OTPManagementException e) { + String msg = "Error occurred while completing the self registration via OTP"; + log.error(msg, e); + throw new OTPManagementException(msg, e); + } + } + + /** + * Invalidate the OTP + * @param oneTimeToken OTP + * @throws OTPManagementException If error occurred while invalidating the OTP + */ + private void invalidateOTP(String oneTimeToken) throws OTPManagementException { try { ConnectionManagerUtil.beginDBTransaction(); if (!otpManagementDAO.expireOneTimeToken(oneTimeToken)) { diff --git a/features/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/user-verify.vm b/features/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/user-verify.vm index 18e3a66a01..858503fd8a 100644 --- a/features/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/user-verify.vm +++ b/features/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/user-verify.vm @@ -16,7 +16,7 @@ under the License. *# - You have been invited to enroll your device in Entgra IoT + Verify email to register with Entgra IoTS diff --git a/features/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/user-welcome.vm b/features/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/user-welcome.vm new file mode 100644 index 0000000000..dfaab5c559 --- /dev/null +++ b/features/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/user-welcome.vm @@ -0,0 +1,101 @@ +#* + Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + + Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*# + + Welcome to Entgra Evaluation Cloud + + + + Entgra IoT Server + + +
+
+
+
+ entgra +
+
+
+

+ Hi $first-name, +

+
+

+ Welcome to Entgra Evaluation Cloud!! Entgra server support offers managing Android, iOS and Windows + devices along with a wide range of features that support cooperate (COPE) or personal device (BYOD) + enrollments. +

+
+
+

Access different portals

+

+ Your log-in credentials to any of our portals(endpoint-mgt, store, publisher) are the same as the + email (username) and password you provided during the registration for an evaluation account. +

+

Endpoint management portal URL: $base-url-https/endpoint-mgt/

+

+ This is the portal used to send operations and policies to devices and overall management of + the server. +

+

Application store portal URL: $base-url-https/store

+

+ This is an in-house corporate app store where you can host all your corporate applications. + Users may browse apps and install them to their devices if the administrator has made the apps + publicly visible to users. Administrator can install, uninstall and update apps in the user + device or device groups. +

+

Application publishing portal URL: $base-url-https/publisher

+

+ The portal for publishing new applications for internal use. This is the developer view of the + enterprise application store that comes with the product. +

+
+
+

Enroll a device

+

+ Please find here a set of videos on how to enroll and onboard devices to our Cloud platform. + [Cloud Enrollment Guide] + When enrolling a device, Make sure to use the following log-in format: +

+

+ Organisation: $tenant-domain + Username: $email-address + Password: password provided at registration. +

+
+
+

+ If you have any further questions, please reach out to us using your registered mail to + bizdev-group@entgra.io. Looking forward to working with you. +

+

+ Best Regards, +

+

+ Entgra Cloud Team +

+
+
+
+
+ + + ]]> + +