1 | |
package booking.controller.common; |
2 | |
|
3 | |
import javax.servlet.ServletContext; |
4 | |
import javax.servlet.http.HttpServletRequest; |
5 | |
import javax.servlet.http.HttpServletResponse; |
6 | |
|
7 | |
import org.springframework.beans.factory.annotation.Autowired; |
8 | |
import org.springframework.stereotype.Controller; |
9 | |
import org.springframework.ui.Model; |
10 | |
import org.springframework.web.bind.annotation.PathVariable; |
11 | |
import org.springframework.web.bind.annotation.RequestMapping; |
12 | |
import org.springframework.web.bind.annotation.RequestMethod; |
13 | |
import org.springframework.web.context.ServletContextAware; |
14 | |
|
15 | |
import booking.model.bo.ServicesBO; |
16 | |
|
17 | |
@Controller |
18 | |
@RequestMapping(value = "/recover") |
19 | 0 | public class RecoveryPasswordController implements ServletContextAware { |
20 | |
|
21 | |
protected ServletContext servletContext; |
22 | |
|
23 | |
@Autowired |
24 | |
ServicesBO servicesBO; |
25 | |
|
26 | |
@Override |
27 | |
public void setServletContext(ServletContext servletContext) { |
28 | 0 | this.servletContext = servletContext; |
29 | |
|
30 | 0 | } |
31 | |
|
32 | |
@RequestMapping(value = "/recovery_success") |
33 | |
public String goRecoverySuccessPage(HttpServletRequest request, HttpServletResponse response, Model model) { |
34 | 0 | return "recovery_success"; |
35 | |
} |
36 | |
|
37 | |
@RequestMapping(value = "/recovery_fail") |
38 | |
public String goRecoveryFailPage(HttpServletRequest request, HttpServletResponse response, Model model) { |
39 | 0 | return "recovery_fail"; |
40 | |
} |
41 | |
|
42 | |
@RequestMapping(value = "/password/{login}/{hash}", method = RequestMethod.GET) |
43 | |
public String goRecoveryPage(HttpServletRequest request, HttpServletResponse response, Model model, |
44 | |
@PathVariable("login") String login, @PathVariable("hash") String hash) { |
45 | |
|
46 | 0 | if (servicesBO.checkRecoveryPassword(login, hash)) { |
47 | |
|
48 | 0 | request.setAttribute("login", login); |
49 | 0 | request.setAttribute("hash", hash); |
50 | 0 | return "recovery"; |
51 | |
|
52 | |
} else { |
53 | 0 | return "recovery_fail"; |
54 | |
} |
55 | |
} |
56 | |
} |