| 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",
|
|
|
36 |
params = {"actionName" , "login-details"})
|
|
|
37 |
})
|
| 517 |
rajveer |
38 |
public class LoginDetailsController extends BaseController
|
| 507 |
rajveer |
39 |
implements ParameterAware {
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
*
|
|
|
44 |
*/
|
| 595 |
rajveer |
45 |
private static final long serialVersionUID = 1L;
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
*
|
|
|
49 |
*/
|
| 517 |
rajveer |
50 |
private static Log log = LogFactory.getLog(LoginDetailsController.class);
|
| 507 |
rajveer |
51 |
|
| 595 |
rajveer |
52 |
private Map<String,String> htmlSnippets = new HashMap<String, String>();
|
| 507 |
rajveer |
53 |
/**
|
|
|
54 |
*
|
|
|
55 |
*/
|
|
|
56 |
|
|
|
57 |
private Map<String, String[]> reqparams;
|
|
|
58 |
|
| 517 |
rajveer |
59 |
public LoginDetailsController() {
|
| 507 |
rajveer |
60 |
super();
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
// POST /logindetails
|
|
|
64 |
public String create() {
|
|
|
65 |
log.info("LogindetailsController.create");
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
String email = this.request.getParameter("txtLoginID");
|
|
|
69 |
String oldPassword = this.request.getParameter("txtOldPassword");
|
|
|
70 |
String newPassword = this.request.getParameter("txtNewPassword");
|
|
|
71 |
|
|
|
72 |
if(this.userinfo.isLoggedIn()){
|
|
|
73 |
if(Utils.ChangePassword(userinfo.getUserId(), email, oldPassword, newPassword))
|
|
|
74 |
{
|
| 595 |
rajveer |
75 |
addActionMessage("Your password is updated successfully.");
|
| 507 |
rajveer |
76 |
return "success";
|
|
|
77 |
}
|
|
|
78 |
}
|
| 595 |
rajveer |
79 |
addActionError("Unable to update password. Either email or password is not correct.");
|
|
|
80 |
return "success";
|
| 507 |
rajveer |
81 |
}
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
// GET /test
|
|
|
85 |
public HttpHeaders index() throws UnsupportedEncodingException {
|
|
|
86 |
log.info("this.request=" + this.request);
|
|
|
87 |
|
|
|
88 |
if(this.userinfo.isLoggedIn()){
|
| 595 |
rajveer |
89 |
PageLoaderHandler pageLoader = new PageLoaderHandler();
|
|
|
90 |
|
|
|
91 |
htmlSnippets.put("HEADER", pageLoader.getHeaderHtml(this.userinfo.isLoggedIn(), this.userinfo.getNameOfUser()));
|
|
|
92 |
htmlSnippets.put("MAIN_MENU", pageLoader.getMainMenuHtml());
|
|
|
93 |
htmlSnippets.put("SEARCH_BAR", pageLoader.getSearchBarHtml(userinfo.getTotalItems(), 0));
|
|
|
94 |
htmlSnippets.put("MYACCOUNT_HEADER", pageLoader.getMyaccountHeaderHtml());
|
|
|
95 |
|
|
|
96 |
htmlSnippets.put("CUSTOMER_SERVICE", pageLoader.getCustomerServiceHtml());
|
|
|
97 |
htmlSnippets.put("MY_RESEARCH", pageLoader.getMyResearchHtml(userinfo.getUserId(), true));
|
|
|
98 |
htmlSnippets.put("BROWSE_HISTORY", pageLoader.getBrowseHistoryHtml(userinfo.getUserId(), userinfo.isLoggedIn()));
|
|
|
99 |
htmlSnippets.put("FOOTER", pageLoader.getFooterHtml());
|
|
|
100 |
|
|
|
101 |
return new DefaultHttpHeaders("index").disableCaching();
|
| 507 |
rajveer |
102 |
|
|
|
103 |
}else{
|
|
|
104 |
return new DefaultHttpHeaders("login").disableCaching();
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
public String getHeaderSnippet(){
|
|
|
110 |
return htmlSnippets.get("HEADER");
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
public String getMainMenuSnippet(){
|
|
|
114 |
return htmlSnippets.get("MAIN_MENU");
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
public String getSearchBarSnippet(){
|
|
|
118 |
return htmlSnippets.get("SEARCH_BAR");
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
public String getCustomerServiceSnippet(){
|
|
|
123 |
return htmlSnippets.get("CUSTOMER_SERVICE");
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
public String getMyaccountHeaderSnippet(){
|
|
|
127 |
return htmlSnippets.get("MYACCOUNT_HEADER");
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
public String getLoginDetailsSnippet(){
|
|
|
131 |
return htmlSnippets.get("LOGIN_DETAILS");
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
public String getMyResearchSnippet(){
|
|
|
135 |
return htmlSnippets.get("MY_RESEARCH");
|
|
|
136 |
}
|
| 595 |
rajveer |
137 |
|
|
|
138 |
public String getBrowseHistorySnippet(){
|
|
|
139 |
return htmlSnippets.get("BROWSE_HISTORY");
|
|
|
140 |
}
|
|
|
141 |
|
| 507 |
rajveer |
142 |
public String getFooterSnippet(){
|
|
|
143 |
return htmlSnippets.get("FOOTER");
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
public String getJsFileSnippet(){
|
|
|
147 |
return htmlSnippets.get("JS_FILES");
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
public String getCssFileSnippet(){
|
|
|
151 |
return htmlSnippets.get("CSS_FILES");
|
|
|
152 |
}
|
|
|
153 |
|
| 595 |
rajveer |
154 |
public String getEmail(){
|
|
|
155 |
return userinfo.getEmail();
|
| 507 |
rajveer |
156 |
}
|
|
|
157 |
|
|
|
158 |
@Override
|
|
|
159 |
public void setParameters(Map<String, String[]> reqmap) {
|
|
|
160 |
log.info("setParameters:" + reqmap);
|
|
|
161 |
|
|
|
162 |
this.reqparams = reqmap;
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
}
|