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