Revision 49683
Added by Sofia Baltzi over 6 years ago
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java | ||
---|---|---|
97 | 97 |
request.getSession().setAttribute("message", "Error sending email."); |
98 | 98 |
response.sendRedirect("./forgotPassword.jsp"); |
99 | 99 |
} |
100 |
|
|
100 |
|
|
101 | 101 |
} |
102 | 102 |
|
103 | 103 |
} |
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/RegisterServlet.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.usermanagement; |
2 | 2 |
|
3 |
import eu.dnetlib.openaire.user.utils.EmailSender; |
|
3 | 4 |
import eu.dnetlib.openaire.user.utils.LDAPActions; |
4 | 5 |
import eu.dnetlib.openaire.user.utils.VerificationActions; |
5 | 6 |
import org.apache.log4j.Logger; |
... | ... | |
13 | 14 |
import javax.servlet.http.HttpServletResponse; |
14 | 15 |
import java.io.IOException; |
15 | 16 |
import java.io.PrintWriter; |
17 |
import java.sql.Timestamp; |
|
18 |
import java.util.Date; |
|
19 |
import java.util.UUID; |
|
16 | 20 |
|
17 | 21 |
/** |
18 | 22 |
* Created by sofia on 20/10/2017. |
... | ... | |
29 | 33 |
private VerificationActions verificationActions; |
30 | 34 |
|
31 | 35 |
@Autowired |
36 |
private EmailSender emailSender; |
|
37 |
|
|
38 |
@Autowired |
|
32 | 39 |
private LDAPActions ldapActions; |
33 | 40 |
|
34 | 41 |
private Logger logger = Logger.getLogger(RegisterServlet.class); |
... | ... | |
55 | 62 |
if (firstName != null && lastName != null && username != null && |
56 | 63 |
email.equals(confirmEmail) /*&& password.equals(confirmPassword)*/ ) { |
57 | 64 |
try { |
58 |
ldapActions.createUser(username, email, firstName, lastName, organization/*, password*/); |
|
59 |
logger.info("User successfully created"); |
|
65 |
|
|
66 |
// if (ldapActions.usernameExists(username)) { |
|
67 |
// request.getSession().setAttribute("username_message", "Username already exists! Choose another one."); |
|
68 |
// logger.info("Username already exists"); |
|
69 |
// response.sendRedirect("./register.jsp"); |
|
70 |
// |
|
71 |
// } else if (ldapActions.emailExists(email)) { |
|
72 |
// request.getSession().setAttribute("email_message", "There is another user with this email."); |
|
73 |
// logger.info("There is another user with this email"); |
|
74 |
// response.sendRedirect("./register.jsp"); |
|
75 |
// |
|
76 |
// } else { |
|
77 |
|
|
78 |
ldapActions.createUser(username, email, firstName, lastName, organization/*, password*/); |
|
79 |
logger.info("User successfully created"); |
|
80 |
|
|
81 |
UUID verificationCode = UUID.randomUUID(); |
|
82 |
Date creationDate = new Date(); |
|
83 |
|
|
84 |
Timestamp timestamp = new Timestamp(creationDate.getTime()); |
|
85 |
|
|
86 |
if (!verificationActions.verificationEntryExists(username)) { |
|
87 |
verificationActions.addVerificationEntry(username, verificationCode.toString(), timestamp); |
|
88 |
|
|
89 |
} else { |
|
90 |
verificationActions.updateVerificationEntry(username, verificationCode.toString(), timestamp); |
|
91 |
} |
|
92 |
|
|
93 |
String verificationCodeMsg = "Hello " + username + ",\n" + |
|
94 |
"\n" + |
|
95 |
"A request has been made to verify your email and activate your OpenAIRE account. To activate your\n" + |
|
96 |
"account, you will need to submit your username and this activation code in order to verify that the\n" + |
|
97 |
"request was legitimate.\n" + |
|
98 |
"\n" + |
|
99 |
"The activation code is " + verificationCode.toString() + "\n Thank you"; |
|
100 |
|
|
101 |
String verificationCodeSubject = "Your OpenAIRE password reset request"; |
|
102 |
|
|
103 |
emailSender.sendEmail(email, verificationCodeSubject, verificationCodeMsg); |
|
104 |
|
|
105 |
|
|
106 |
response.sendRedirect("./activate.jsp"); |
|
107 |
// } |
|
108 |
|
|
60 | 109 |
} catch (Exception e) { |
61 | 110 |
logger.error("LDAP error in creating user", e); |
62 | 111 |
response.sendRedirect("./error.jsp"); |
63 | 112 |
} |
64 | 113 |
} |
65 |
response.sendRedirect("./activate.jsp"); |
|
66 | 114 |
printWriter.close(); |
67 | 115 |
|
68 | 116 |
} |
modules/dnet-openaire-users/trunk/src/main/webapp/register.jsp | ||
---|---|---|
17 | 17 |
<script src="./js/jquery.js"></script> |
18 | 18 |
<script src="./js/uikit.js"></script> |
19 | 19 |
<script src="./js/validation.js"></script> |
20 |
<script src="./OpenAIRE_files/uikit-icons-max.js"></script>
|
|
20 |
<script src="./js/uikit-icons-max.js"></script>
|
|
21 | 21 |
<link rel="stylesheet" style="text/css" href="./css/theme.css"> |
22 | 22 |
<link rel="stylesheet" style="text/css" href="./css/custom.css"> |
23 | 23 |
<link rel="stylesheet" style="text/css" href="./css/aai-custom.css"> |
... | ... | |
56 | 56 |
<div class="uk-width-1-3@m uk-align-center"> |
57 | 57 |
<!-- REGISTER FORM --> |
58 | 58 |
<div id="registerForm"> |
59 |
<form action="register" method="POST" target="GWTBootstrap3_AbstractForm_RepositoryManager_1" role="form" class="m-t" id="register_form">
|
|
59 |
<form action="register" method="POST" role="form" class="m-t" id="register_form"> |
|
60 | 60 |
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> |
61 | 61 |
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div> |
62 | 62 |
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div> |
... | ... | |
72 | 72 |
<span class="msg_username_min_lenght uk-text-danger uk-text-small uk-float-left" style="display:none">Minimum username length 5 characters.</span> |
73 | 73 |
<span class="msg_username_max_lenght uk-text-danger uk-text-small uk-float-left" style="display:none">Maximum username lenght 150 characters.</span> |
74 | 74 |
<span class="msg_username_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your username.</span> |
75 |
<%--<span id="username_server_error" class="uk-text-danger uk-text-small uk-float-left">${username_message}</span>--%> |
|
76 |
<%--<c:remove var="username_message" scope="session" />--%> |
|
75 | 77 |
<input id="username" name="username" type="text" placeholder="Username (*)" class="form-control"></div> |
76 | 78 |
<div class="form-group"> |
77 | 79 |
<span class="msg_email_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your email.</span> |
78 | 80 |
<span class="msg_email_validation_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter a valid email.</span> |
79 | 81 |
<span class="msg_email_conf_error uk-text-danger uk-text-small uk-float-left" style="display:none">These emails don't match.</span> |
82 |
<%--<span id="email_server_error" class="uk-text-danger uk-text-small uk-float-left">${email_message}</span>--%> |
|
83 |
<%--<c:remove var="email_message" scope="session" />--%> |
|
80 | 84 |
<input id="email" name="email" type="text" placeholder="Email (*)" class="form-control"></div> |
81 | 85 |
<div class="form-group"> |
82 | 86 |
<input id="email_conf" name="email_conf" type="text" placeholder="Confirm email (*)" class="form-control"></div> |
... | ... | |
185 | 189 |
$("#username").focusin(function () { |
186 | 190 |
$(this).removeClass('aai-form-danger'); |
187 | 191 |
$(".msg_username_error").fadeOut(); |
192 |
// $(".username_server_error").fadeOut(); |
|
188 | 193 |
}); |
189 | 194 |
|
190 | 195 |
$("#email").focusin(function () { |
191 | 196 |
$(this).removeClass('aai-form-danger'); |
192 | 197 |
$(".msg_email_error").fadeOut(); |
193 | 198 |
$(".msg_email_validation_error").fadeOut(); |
199 |
// $(".email_server_error").fadeOut(); |
|
194 | 200 |
}); |
195 | 201 |
|
196 | 202 |
$("#email_conf").focusin(function () { |
Also available in: Unified diff
Add emailSender at register