From eeee0ed9d1b1eac2e5da9feedf36f5a47ed0fc91 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 4 Apr 2023 17:47:57 +0530 Subject: [PATCH] Fix eval tenant creating issue --- .../core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java | 2 +- .../mgt/core/otp/mgt/service/OTPManagementServiceImpl.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java index 371e752884..574d6e7904 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java @@ -214,7 +214,7 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM + "SET " + "OTP_TOKEN = ?, " + "CREATED_AT = ?, " - + "IS_EXPIRED = false" + + "IS_EXPIRED = false " + "WHERE ID = ?"; try { 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 d9a0fdbf55..4c8161e100 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 @@ -91,6 +91,7 @@ public class OTPManagementServiceImpl implements OTPManagementService { public OneTimePinDTO getRenewedOtpByEmailAndMailType(String email, String emailType) throws OTPManagementException{ OneTimePinDTO oneTimePinDTO; + String newToken = UUID.randomUUID().toString(); try { ConnectionManagerUtil.beginDBTransaction(); oneTimePinDTO = otpManagementDAO.getOtpDataByEmailAndMailType(email, emailType); @@ -100,9 +101,9 @@ public class OTPManagementServiceImpl implements OTPManagementService { log.error(msg); throw new OTPManagementException(msg); } - otpManagementDAO.restoreOneTimeToken(oneTimePinDTO.getId(), UUID.randomUUID().toString()); + otpManagementDAO.restoreOneTimeToken(oneTimePinDTO.getId(), newToken); ConnectionManagerUtil.commitDBTransaction(); - return oneTimePinDTO; + } catch (DBConnectionException e) { ConnectionManagerUtil.rollbackDBTransaction(); String msg = "Error occurred while getting database connection to validate the given email and email type."; @@ -120,6 +121,8 @@ public class OTPManagementServiceImpl implements OTPManagementService { } finally { ConnectionManagerUtil.closeDBConnection(); } + oneTimePinDTO.setOtpToken(newToken); + return oneTimePinDTO; } @Override