Project

General

Profile

« Previous | Next » 

Revision 49349

Added by Sofia Baltzi over 6 years ago

Change date type to timestamp and add email verification message

View differences:

ForgotPasswordServlet.java
14 14
import javax.servlet.http.HttpServletRequest;
15 15
import javax.servlet.http.HttpServletResponse;
16 16
import java.io.IOException;
17
import java.sql.Timestamp;
17 18
import java.util.Date;
18 19
import java.util.UUID;
19 20

  
......
35 36
    @Autowired
36 37
    private VerificationActions verificationActions;
37 38

  
38
    private EmailActions emailActions;
39
    @Autowired
40
    private EmailSender emailSender;
39 41

  
40 42
    private Logger logger = Logger.getLogger(ForgotPasswordServlet.class);
41 43

  
......
50 52
        }
51 53

  
52 54
        try {
55

  
53 56
            String username = ldapActions.getUsername(formEmail);
54 57

  
55 58
            if (username == null) {
......
60 63
                UUID verificationCode = UUID.randomUUID();
61 64
                Date creationDate = new Date();
62 65

  
63
                if (verificationActions.verificationEntryExists(username)) {
64
                    verificationActions.addVerificationEntry(username, verificationCode.toString(), creationDate);
66
                Timestamp timestamp = new Timestamp(creationDate.getTime());
65 67

  
68
                //logger.info("verificationCode = " + verificationCode);
69

  
70
                if (!verificationActions.verificationEntryExists(username)) {
71
                    verificationActions.addVerificationEntry(username, verificationCode.toString(), timestamp);
72

  
66 73
                } else {
67
                    verificationActions.updateVerificationEntry(username, verificationCode.toString(), creationDate);
74
                    verificationActions.updateVerificationEntry(username, verificationCode.toString(), timestamp);
68 75
                }
69 76

  
70
                emailActions.sendVerificationCode(formEmail);
77
                String verificationCodeMsg = "Hello,\n" +
78
                        "\n" +
79
                        "A request has been made to reset your OpenAIRE account password. To reset your\n" +
80
                        "password, you will need to submit this verification code in order to verify that the\n" +
81
                        "request was legitimate.\n" +
82
                        "\n" +
83
                        "The verification code is" + verificationCode.toString() + "\n Thank you";
71 84

  
85
                verificationCodeSubject = "Your OpenAIRE password reset request";
86

  
87
                emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg)
88

  
72 89
            }
73 90

  
74 91

  

Also available in: Unified diff