| 507 |
rajveer |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.serving.controllers;
|
|
|
5 |
import in.shop2020.serving.utils.Utils;
|
|
|
6 |
|
|
|
7 |
import java.io.UnsupportedEncodingException;
|
|
|
8 |
|
|
|
9 |
import org.apache.juli.logging.Log;
|
|
|
10 |
import org.apache.juli.logging.LogFactory;
|
|
|
11 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
12 |
import org.apache.struts2.convention.annotation.Results;
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* @author rajveer
|
|
|
16 |
*
|
|
|
17 |
*/
|
|
|
18 |
|
| 595 |
rajveer |
19 |
@Results({
|
|
|
20 |
@Result(name="success", type="redirectAction",
|
| 650 |
rajveer |
21 |
params = {"actionName" , "login-details"}),
|
|
|
22 |
@Result(name="redirect", type="redirectAction",
|
|
|
23 |
params = {"actionName" , "login"})
|
| 595 |
rajveer |
24 |
})
|
| 650 |
rajveer |
25 |
public class LoginDetailsController extends BaseController {
|
| 507 |
rajveer |
26 |
|
| 595 |
rajveer |
27 |
private static final long serialVersionUID = 1L;
|
|
|
28 |
|
| 517 |
rajveer |
29 |
private static Log log = LogFactory.getLog(LoginDetailsController.class);
|
| 507 |
rajveer |
30 |
|
|
|
31 |
|
| 517 |
rajveer |
32 |
public LoginDetailsController() {
|
| 507 |
rajveer |
33 |
super();
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
// POST /logindetails
|
|
|
37 |
public String create() {
|
|
|
38 |
log.info("LogindetailsController.create");
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
String email = this.request.getParameter("txtLoginID");
|
|
|
42 |
String oldPassword = this.request.getParameter("txtOldPassword");
|
|
|
43 |
String newPassword = this.request.getParameter("txtNewPassword");
|
|
|
44 |
|
|
|
45 |
if(this.userinfo.isLoggedIn()){
|
|
|
46 |
if(Utils.ChangePassword(userinfo.getUserId(), email, oldPassword, newPassword))
|
|
|
47 |
{
|
| 595 |
rajveer |
48 |
addActionMessage("Your password is updated successfully.");
|
| 507 |
rajveer |
49 |
return "success";
|
|
|
50 |
}
|
|
|
51 |
}
|
| 595 |
rajveer |
52 |
addActionError("Unable to update password. Either email or password is not correct.");
|
|
|
53 |
return "success";
|
| 507 |
rajveer |
54 |
}
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
// GET /test
|
| 650 |
rajveer |
58 |
public String index() throws UnsupportedEncodingException {
|
| 507 |
rajveer |
59 |
log.info("this.request=" + this.request);
|
|
|
60 |
|
| 650 |
rajveer |
61 |
if(!userinfo.isLoggedIn()){
|
|
|
62 |
setRedirectUrl();
|
|
|
63 |
return "redirect";
|
|
|
64 |
}else{
|
| 595 |
rajveer |
65 |
htmlSnippets.put("MYACCOUNT_HEADER", pageLoader.getMyaccountHeaderHtml());
|
| 650 |
rajveer |
66 |
htmlSnippets.put("LOGIN_DETAILS", pageLoader.getLoginDetailsHtml(userinfo.getUserId()));
|
|
|
67 |
return "index";
|
| 507 |
rajveer |
68 |
}
|
|
|
69 |
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
public String getMyaccountHeaderSnippet(){
|
|
|
73 |
return htmlSnippets.get("MYACCOUNT_HEADER");
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
public String getLoginDetailsSnippet(){
|
|
|
77 |
return htmlSnippets.get("LOGIN_DETAILS");
|
|
|
78 |
}
|
|
|
79 |
|
| 650 |
rajveer |
80 |
public String getEmail(){
|
| 595 |
rajveer |
81 |
return userinfo.getEmail();
|
| 507 |
rajveer |
82 |
}
|
|
|
83 |
|
|
|
84 |
}
|