Revision 51775
Added by Sofia Baltzi about 6 years ago
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/utils/UrlConstructor.java | ||
---|---|---|
3 | 3 |
import org.apache.log4j.Logger; |
4 | 4 |
|
5 | 5 |
import javax.servlet.http.HttpServletRequest; |
6 |
import java.util.UUID; |
|
6 | 7 |
|
7 | 8 |
/** |
8 | 9 |
* Created by sofia on 8/3/2018. |
... | ... | |
47 | 48 |
return resultPath; |
48 | 49 |
} |
49 | 50 |
|
51 |
public static String getVerificationLink(String path , String verificationCode ) { |
|
52 |
|
|
53 |
return path + "?code=" + verificationCode; |
|
54 |
|
|
55 |
} |
|
56 |
|
|
50 | 57 |
} |
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java | ||
---|---|---|
86 | 86 |
} else { |
87 | 87 |
UUID verificationCode = UUID.randomUUID(); |
88 | 88 |
Date creationDate = new Date(); |
89 |
String vCode = verificationCode.toString(); |
|
89 | 90 |
|
90 | 91 |
Timestamp timestamp = new Timestamp(creationDate.getTime()); |
91 | 92 |
|
92 | 93 |
if (!verificationActions.verificationEntryExists(username)) { |
93 |
verificationActions.addVerificationEntry(username, verificationCode.toString(), timestamp);
|
|
94 |
verificationActions.addVerificationEntry(username, vCode, timestamp);
|
|
94 | 95 |
|
95 | 96 |
} else { |
96 |
verificationActions.updateVerificationEntry(username, verificationCode.toString(), timestamp);
|
|
97 |
verificationActions.updateVerificationEntry(username, vCode, timestamp);
|
|
97 | 98 |
} |
98 | 99 |
|
99 | 100 |
String resultPath = UrlConstructor.getRedirectUrl(request, "verify.jsp"); |
101 |
String resultPathWithVCode = UrlConstructor.getVerificationLink(resultPath, vCode); |
|
100 | 102 |
|
101 | 103 |
String verificationCodeMsg = "<p>Hello,</p>" + |
102 | 104 |
"<p> A request has been made to reset your OpenAIRE account password. To reset your " + |
103 | 105 |
"password, you will need to submit this verification code in order to verify that the " + |
104 | 106 |
"request was legitimate.</p>" + |
105 |
"<p> The verification code is " + verificationCode.toString() + "</p>" +
|
|
107 |
"<p> The verification code is " + vCode + "</p>" +
|
|
106 | 108 |
"Click the URL below and proceed with verification." + |
107 |
"<p><a href=" + resultPath + ">" + resultPath + "</a></p>" +
|
|
109 |
"<p><a href=" + resultPathWithVCode + ">" + resultPathWithVCode + "</a></p>" +
|
|
108 | 110 |
"<p>Thank you</p>"; |
109 | 111 |
|
110 | 112 |
String verificationCodeSubject = "Your OpenAIRE password reset request"; |
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/RegisterServlet.java | ||
---|---|---|
92 | 92 |
|
93 | 93 |
UUID verificationCode = UUID.randomUUID(); |
94 | 94 |
Date creationDate = new Date(); |
95 |
String vCode = verificationCode.toString(); |
|
95 | 96 |
|
96 | 97 |
Timestamp timestamp = new Timestamp(creationDate.getTime()); |
97 | 98 |
|
98 | 99 |
if (!verificationActions.verificationEntryExists(username)) { |
99 |
verificationActions.addVerificationEntry(username, verificationCode.toString(), timestamp);
|
|
100 |
verificationActions.addVerificationEntry(username, vCode, timestamp);
|
|
100 | 101 |
|
101 | 102 |
} else { |
102 |
verificationActions.updateVerificationEntry(username, verificationCode.toString(), timestamp);
|
|
103 |
verificationActions.updateVerificationEntry(username, vCode, timestamp);
|
|
103 | 104 |
} |
104 | 105 |
|
105 | 106 |
String resultPath = UrlConstructor.getRedirectUrl(request, "activate.jsp"); |
107 |
String resultPathWithVCode = UrlConstructor.getVerificationLink(resultPath, vCode); |
|
106 | 108 |
|
107 | 109 |
String verificationCodeMsg = "<p>Hello " + username + ",</p>" + |
108 | 110 |
"<p> A request has been made to verify your email and activate your OpenAIRE account. To activate your " + |
109 | 111 |
"account, you will need to submit your username and this activation code in order to verify that the" + |
110 | 112 |
"request was legitimate.</p>" + |
111 | 113 |
"<p>" + |
112 |
"The activation code is " + verificationCode.toString() +
|
|
114 |
"The activation code is " + vCode +
|
|
113 | 115 |
"</p>" + |
114 | 116 |
"Click the URL below and proceed with activating your password." + |
115 |
"<p><a href=" + resultPath + ">" + resultPath + "</a></p>" +
|
|
117 |
"<p><a href=" + resultPathWithVCode + ">" + resultPathWithVCode + "</a></p>" +
|
|
116 | 118 |
"<p>Thank you</p>"; |
117 | 119 |
|
118 | 120 |
String verificationCodeSubject = "Activate your OpenAIRE account"; |
Also available in: Unified diff
Add verificationCode in email's verificationLink for registration and forgot password