Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KB-3119 | Enhancement of the API for the OTP generation for email/phone verification #64

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions service/src/main/java/org/sunbird/actor/otp/OTPActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,15 @@ private void verifyOTPV3(Request request) throws JsonProcessingException {
request.getRequestContext(),
"OTP_VALIDATION_SUCCESS:OTPActor:verifyOTP: Verified successfully Key = "
+ OTPUtil.maskId(key, type));
Map<String, Object> parametersMap = new HashMap<>();
parametersMap.put(JsonKey.TYPE, type);
parametersMap.put(JsonKey.KEY, key);
Map<String,String> contextDetailsMap = new HashMap<>();
contextDetailsMap.put(JsonKey.CONTEXT_TYPE,(String) otpDetails.get(JsonKey.CONTEXT_TYPE));
contextDetailsMap.put(JsonKey.CONTEXT_ATTRIBUTES,(String)otpDetails.get(JsonKey.CONTEXT_ATTRIBUTES));
String contextToken = generateToken(mapper.writeValueAsString(contextDetailsMap));
parametersMap.put(JsonKey.CONTEXT_TOKEN, contextToken);
otpService.updateOTPDetailsV3(parametersMap, request.getRequestContext());
Map<String, Object> compostieKeyMap = new HashMap<>();
compostieKeyMap.put(JsonKey.TYPE, type);
compostieKeyMap.put(JsonKey.KEY, key);
Map<String,Object> requestParamsMap = new HashMap<>();
requestParamsMap.put(JsonKey.CONTEXT_TYPE, otpDetails.get(JsonKey.CONTEXT_TYPE));
requestParamsMap.put(JsonKey.CONTEXT_ATTRIBUTES,otpDetails.get(JsonKey.CONTEXT_ATTRIBUTES));
String contextToken = generateToken(mapper.writeValueAsString(requestParamsMap));
requestParamsMap.put(JsonKey.CONTEXT_TOKEN, contextToken);
otpService.updateOTPDetailsV3(JsonKey.SUNBIRD,JsonKey.OTP,requestParamsMap,compostieKeyMap, request.getRequestContext());
Response response = new Response();
response.put(JsonKey.RESPONSE, JsonKey.SUCCESS);
response.put(JsonKey.CONTEXT_TOKEN,contextToken);
Expand Down
7 changes: 1 addition & 6 deletions service/src/main/java/org/sunbird/dao/otp/OTPDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ public interface OTPDao {
/**
* Updates the OTP (One-Time Password) details based on the provided parameters map.
* This method is responsible for updating OTP details in the system.
*
* @param parametersMap A map containing parameters for updating OTP details.
* It may include information such as type, key, and context token.
* @param requestContext The request context associated with the update operation,
* providing contextual information for the update process.
*/
void updateOTPDetailsV3(Map<String, Object> parametersMap, RequestContext requestContext);
void updateOTPDetailsV3(String keyspaceName, String tableName, Map<String, Object> request, Map<String, Object> compositeKey, RequestContext context);

}
16 changes: 4 additions & 12 deletions service/src/main/java/org/sunbird/dao/otp/impl/OTPDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,11 @@ public Map<String, Object> getOTPDetailsV3(String type, String key, RequestConte
return otpMapList.get(0);
}

/**
* Overrides the method to update OTP (One-Time Password) details based on the provided parameters map.
* This method delegates the update operation to the Cassandra database operation.
*
* @param parametersMap A map containing parameters for updating OTP details.
* It may include information such as type, key, and context token.
* @param requestContext The request context associated with the update operation,
* providing contextual information for the update process.
*/
@Override
public void updateOTPDetailsV3(Map<String, Object> parametersMap, RequestContext requestContext) {
// Delegate the update operation to the Cassandra database operation
cassandraOperation.upsertRecord(JsonKey.SUNBIRD, TABLE_NAME, parametersMap, requestContext);
public void updateOTPDetailsV3(String keyspaceName, String tableName, Map<String, Object> request, Map<String, Object> compositeKey, RequestContext context) {
String expirationInSeconds = PropertiesCache.getInstance().getProperty(JsonKey.OTP_EXPIRATION_TIME_TOKEN);
int ttl = Integer.valueOf(expirationInSeconds)/1000;
cassandraOperation.updateRecordWithTTL(keyspaceName, tableName, request, compositeKey,ttl,context);
}

}
6 changes: 2 additions & 4 deletions service/src/main/java/org/sunbird/service/otp/OTPService.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ public Map<String, Object> getOTPDetailsV3(String type, String key,RequestContex
/**
* Updates the OTP (One-Time Password) details based on the provided parameters map.
* This method delegates the update operation to the OTP DAO (Data Access Object).
* @param parametersMap A map containing parameters for updating OTP details.
* @param requestContext The request context associated with the update operation.
*/
public void updateOTPDetailsV3(Map<String, Object> parametersMap, RequestContext requestContext) {
public void updateOTPDetailsV3(String keyspaceName, String tableName, Map<String, Object> request, Map<String, Object> compositeKey, RequestContext context) {
// Delegate the update operation to the OTP DAO
otpDao.updateOTPDetailsV3(parametersMap, requestContext);
otpDao.updateOTPDetailsV3(keyspaceName, tableName, request, compositeKey,context);
}

}