1
|
package eu.dnetlib.openaire.usermanagement;
|
2
|
|
3
|
import eu.dnetlib.openaire.user.utils.VerificationActions;
|
4
|
import org.springframework.beans.factory.annotation.Autowired;
|
5
|
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
|
6
|
|
7
|
import javax.servlet.ServletConfig;
|
8
|
import javax.servlet.ServletException;
|
9
|
import javax.servlet.http.HttpServlet;
|
10
|
import javax.servlet.http.HttpServletRequest;
|
11
|
import javax.servlet.http.HttpServletResponse;
|
12
|
import java.io.IOException;
|
13
|
import java.io.PrintWriter;
|
14
|
|
15
|
/**
|
16
|
* Created by kiatrop on 28/9/2017.
|
17
|
*/
|
18
|
public class VerificationCodeServlet extends HttpServlet {
|
19
|
|
20
|
public void init(ServletConfig config) throws ServletException {
|
21
|
super.init(config);
|
22
|
SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this,
|
23
|
config.getServletContext());
|
24
|
}
|
25
|
|
26
|
@Autowired
|
27
|
private VerificationActions verificationActions;
|
28
|
|
29
|
@Override
|
30
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
31
|
response.setContentType("text/html");
|
32
|
PrintWriter printWriter = response.getWriter();
|
33
|
|
34
|
String formUsername = (String)request.getAttribute("username");
|
35
|
String formVerificationCode = (String)request.getAttribute("verification_code");
|
36
|
|
37
|
if (verificationActions.verificationEntryExists(formUsername, formVerificationCode)) {
|
38
|
response.sendRedirect("./resetPassword.jsp");
|
39
|
|
40
|
} else {
|
41
|
response.sendRedirect("./error.jsp");
|
42
|
}
|
43
|
|
44
|
response.sendRedirect("./resetPassword.jsp");
|
45
|
printWriter.close();
|
46
|
}
|
47
|
}
|