Skip to content

Commit b933fc6

Browse files
authored
Merge pull request #12 from motech-implementations/emailId_change_in_forgot_pswd_api
From email address change in forgot password api
2 parents ed48d7b + 03b3994 commit b933fc6

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

Email/NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/controller/EmailController.java

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,41 @@ String sendPassword(@PathVariable String encoded) throws Exception {
5959
byte[] decoded = Base64.decodeBase64(encoded);
6060
String token = new String(decoded, "UTF-8");
6161
String[] tokenItems = token.split("\\|\\|");
62-
62+
//changed the 'from' emailId from beehyv domain address to govt domain address
6363
String email = tokenItems[0];
6464
String password = tokenItems[1];
65-
EmailInfo newMail = new EmailInfo();
66-
newMail.setFrom("nsp-reports@beehyv.com");
67-
newMail.setTo(email);
68-
Calendar c = Calendar.getInstance(); // this takes current date
69-
c.add(Calendar.MONTH, -1);
70-
c.set(Calendar.DATE, 1);
71-
newMail.setSubject("Reset Password for MIS Portal");
72-
newMail.setBody("Dear user,<br/><br/><p>As per your request, your password has been reset to: <b>" +
73-
password +
74-
"</b></p><br/><p>Once you login to the MIS portal with the above password, the system will direct you to change the default password as it is mandatory.</p><br/>" +
75-
"<p>Thanks,</p>" +
76-
"<p>NSP Support</p>");
77-
return emailService.sendMailPassword(newMail);
65+
String subject = "Reset Password for MIS Portal";
66+
String message = "\"Dear user,<br/><br/><p>As per your request, your password has been reset to: <b>" +
67+
password +
68+
"</b></p><br/><p>Once you login to the MIS portal with the above password, the system will direct you to change the default password as it is mandatory.</p><br/>" +
69+
"<p>Thanks,</p>" +"<p>NSP Support</p>\"";
70+
String command = "/opt/sendEmail/sendEmail -f motechnagios@ggn.rcil.gov.in -s email.ggn.rcil.gov.in -t "+
71+
email+" -o \"message-content-type=html\" -m "+message+" -u "+subject;
72+
ProcessBuilder processBuilder = new ProcessBuilder();
73+
processBuilder.command("bash","-c",command);
74+
processBuilder.inheritIO();
75+
try {
76+
Process process = processBuilder.start();
77+
int exitVal = process.waitFor();
78+
if(exitVal==0){
79+
return "success";
80+
}else{
81+
return "failure";
82+
}
83+
}catch (InterruptedException e){return "failure";}
84+
// EmailInfo newMail = new EmailInfo();
85+
// newMail.setFrom("nsp-reports@beehyv.com");
86+
// newMail.setTo(email);
87+
// Calendar c = Calendar.getInstance(); // this takes current date
88+
// c.add(Calendar.MONTH, -1);
89+
// c.set(Calendar.DATE, 1);
90+
// newMail.setSubject("Reset Password for MIS Portal");
91+
// newMail.setBody("Dear user,<br/><br/><p>As per your request, your password has been reset to: <b>" +
92+
// password +
93+
// "</b></p><br/><p>Once you login to the MIS portal with the above password, the system will direct you to change the default password as it is mandatory.</p><br/>" +
94+
// "<p>Thanks,</p>" +
95+
// "<p>NSP Support</p>");
96+
// return emailService.sendMailPassword(newMail);
7897
}
7998

8099
@RequestMapping(value = "/sendCaptcha/{captchaResponse}", method = RequestMethod.GET)

0 commit comments

Comments
 (0)