Skip to content

Commit

Permalink
Merge pull request #12 from RespectNetwork/hotfix-validationCode
Browse files Browse the repository at this point in the history
Signed-off-by: Noopur <[email protected]>
  • Loading branch information
kvats authored Oct 13, 2016
2 parents ba86115 + 0a3c85e commit 99d5888
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/main/java/net/respectnetwork/sdk/csp/BasicUserValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,22 @@ public void sendValidationMessages(String sessionKey, String email, String mobil
+ " check that all required properties are set.");
}

TokenKey emailTokenKey = new TokenKey(sessionKey, "EMAIL", email);
TokenKey smsTokenKey = new TokenKey(sessionKey, "SMS", mobilePhone);
TokenKey emailTokenKey = new TokenKey(sessionKey, "EMAIL");
TokenKey smsTokenKey = new TokenKey(sessionKey, "SMS");

tokenManager.inValidateToken(emailTokenKey);
tokenManager.inValidateToken(smsTokenKey);

if(!Strings.isNullOrEmpty(email)) {
String emailValidationCode = tokenManager.createToken(emailTokenKey);
log.debug("Email Verification Code: {} for emailId: {}", emailValidationCode, email);
Map<String, Object> placeHolders = new HashMap<String, Object>();
placeHolders.put("emailValidationCode", emailValidationCode);
theNotifier.sendEmailNotification("ValidationCode", email, cspName, placeHolders);
}
if(!Strings.isNullOrEmpty(mobilePhone)){
String smsValidationCode = tokenManager.createToken(smsTokenKey);
log.debug("SMS Verification Code: {} for phoneNumber: {}", smsValidationCode, mobilePhone);
String smsMessage = messageManager.createSMSMessage(smsValidationCode, cspName);
theNotifier.sendSMSNotification(mobilePhone, smsMessage);
}
tokenManager.inValidateToken(smsTokenKey);

String emailValidationCode = tokenManager.createToken(emailTokenKey);
log.debug("Email Verification Code: {}", emailValidationCode);
Map<String, Object> placeHolders = new HashMap<String, Object>();
placeHolders.put("emailValidationCode", emailValidationCode);
theNotifier.sendEmailNotification("ValidationCode", email, cspName, placeHolders);

String smsValidationCode = tokenManager.createToken(smsTokenKey);
log.debug("SMS Verification Code: {}", smsValidationCode, mobilePhone);
String smsMessage = messageManager.createSMSMessage(smsValidationCode, cspName);
theNotifier.sendSMSNotification(mobilePhone, smsMessage);

// done
log.debug("Send ValidationMessages to {} and {}", email, mobilePhone);
Expand All @@ -158,8 +155,8 @@ public boolean validateCodes(String sessionIdentifier, String emailCode, String
try {
boolean result = false;

TokenKey emailTokenKey = new TokenKey(sessionIdentifier, "EMAIL", email);
TokenKey smsTokenKey = new TokenKey(sessionIdentifier, "SMS", phone);
TokenKey emailTokenKey = new TokenKey(sessionIdentifier, "EMAIL");
TokenKey smsTokenKey = new TokenKey(sessionIdentifier, "SMS");

if(!Strings.isNullOrEmpty(emailCode) && Strings.isNullOrEmpty(smsCode)){
result = tokenManager.validateToken(emailTokenKey, emailCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public TokenKey(String cloudNumber, String tokenQualifier, String value) {
this.value = value;
}

public TokenKey(String cloudNumber, String tokenQualifier) {
super();
this.cloudNumber = cloudNumber;
this.tokenQualifier = tokenQualifier;
}

/**
* @return the cloudNumber
*/
Expand Down

0 comments on commit 99d5888

Please sign in to comment.