Subversion Repositories SmartDukaan

Rev

Rev 637 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 637 Rev 650
Line 2... Line 2...
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.serving.controllers;
4
package in.shop2020.serving.controllers;
5
 
5
 
6
 
6
 
7
import in.shop2020.model.v1.user.Phone;
-
 
8
import in.shop2020.model.v1.user.PhoneType;
-
 
9
import in.shop2020.model.v1.user.Sex;
-
 
10
import in.shop2020.model.v1.user.User;
7
import in.shop2020.model.v1.user.User;
11
import in.shop2020.model.v1.user.UserState;
-
 
12
import in.shop2020.serving.pages.PageContentKeys;
-
 
13
import in.shop2020.serving.pages.PageEnum;
-
 
14
import in.shop2020.serving.pages.PageManager;
-
 
15
import in.shop2020.serving.utils.Utils;
8
import in.shop2020.serving.utils.Utils;
16
import in.shop2020.thrift.clients.UserContextServiceClient;
9
import in.shop2020.thrift.clients.UserContextServiceClient;
17
 
10
 
18
import java.io.IOException;
11
import java.io.IOException;
19
import java.util.Date;
12
import java.util.Date;
20
import java.util.GregorianCalendar;
-
 
21
import java.util.HashMap;
-
 
22
import java.util.HashSet;
-
 
23
import java.util.Map;
-
 
24
import java.util.Set;
-
 
25
import java.util.StringTokenizer;
-
 
26
 
-
 
27
import javax.servlet.ServletContext;
-
 
28
import javax.servlet.http.Cookie;
-
 
29
 
13
 
30
import org.apache.juli.logging.Log;
14
import org.apache.juli.logging.Log;
31
import org.apache.juli.logging.LogFactory;
15
import org.apache.juli.logging.LogFactory;
32
import org.apache.struts2.convention.annotation.Action;
16
import org.apache.struts2.convention.annotation.InterceptorRef;
33
import org.apache.struts2.convention.annotation.Actions;
17
import org.apache.struts2.convention.annotation.InterceptorRefs;
34
import org.apache.struts2.convention.annotation.Result;
18
import org.apache.struts2.convention.annotation.Result;
35
import org.apache.struts2.convention.annotation.Results;
19
import org.apache.struts2.convention.annotation.Results;
36
import org.apache.struts2.interceptor.ParameterAware;
-
 
37
import org.apache.struts2.rest.DefaultHttpHeaders;
-
 
38
import org.apache.struts2.rest.HttpHeaders;
-
 
39
import org.apache.struts2.util.ServletContextAware;
-
 
40
 
-
 
41
import com.opensymphony.xwork2.ModelDriven;
-
 
42
 
20
 
43
/**
21
/**
44
 * 
22
 * 
45
 * @author rajveer
23
 * @author rajveer
46
 *
24
 *
Line 48... Line 26...
48
 
26
 
49
@Results({
27
@Results({
50
    @Result(name="success", type="redirectAction", 
28
    @Result(name="success", type="redirectAction", 
51
    		params = {"actionName" , "home"}),
29
    		params = {"actionName" , "home"}),
52
    @Result(name="failure", type="redirectAction", 
30
    @Result(name="failure", type="redirectAction", 
53
       		params = {"actionName" , "login"})
31
       		params = {"actionName" , "login"}),
-
 
32
    @Result(name="redirect", location="${url}", type="redirect")
-
 
33
})
-
 
34
 
-
 
35
@InterceptorRefs({
-
 
36
	@InterceptorRef("defaultStack"),
-
 
37
    @InterceptorRef("restDefaultStack")
54
})
38
})
55
public class LoginController extends BaseController{
39
public class LoginController extends BaseController{
56
		  
40
		  
57
	/**
-
 
58
	 * 
-
 
59
	 */
41
 
60
	private static Log log = LogFactory.getLog(LoginController.class);
42
	private static Log log = LogFactory.getLog(LoginController.class);
61
	
43
	
62
	private Map<String,String> htmlSnippets = new HashMap<String, String>();
44
	private String redirectUrl;
63
	
45
	
64
	public LoginController(){
46
	public LoginController(){
65
		super();
47
		super();
66
	}
48
	}
67
 
49
 
68
 
50
 
69
    public HttpHeaders index() throws SecurityException, IOException {
51
    public String index() throws SecurityException, IOException {
70
    	htmlSnippets.put("LOGIN_HEADER", pageLoader.getLoginHeaderHtml());
52
    	htmlSnippets.put("LOGIN_HEADER", pageLoader.getLoginHeaderHtml());
71
		htmlSnippets.put("LOGIN_FORM", pageLoader.getLoginFormHtml());
53
		htmlSnippets.put("LOGIN_FORM", pageLoader.getLoginFormHtml());
72
		return new DefaultHttpHeaders("index");
54
		return "index";
73
    }
55
    }
74
 
56
 
75
    public String create() throws SecurityException, Exception {
57
    public String create() throws SecurityException, Exception {
76
    	
58
    	
77
    	if(loginUser()){
59
    	if(loginUser()){
-
 
60
    		if(getUrl()!=null){
-
 
61
    			redirectUrl = getUrl();
78
    		this.request.getSession().getAttribute("REDIRECT_URL");	
62
    			resetRedirectUrl();
-
 
63
    			return "redirect";
-
 
64
    		}
79
    		return "success";
65
    		return "success";
80
    	}
66
    	}
81
    	else
67
    	else
82
    		return "failure";
68
    		return "failure";
83
    }
69
    }
Line 112... Line 98...
112
    		log.error("Wrong username or password.");
98
    		log.error("Wrong username or password.");
113
    		return false;
99
    		return false;
114
    	}
100
    	}
115
    }
101
    }
116
 
102
 
117
	public Map<String,String> getHtmlSnippets(){
-
 
118
		System.out.println(" getHtmlSnippets  is called");
-
 
119
		return htmlSnippets;
-
 
120
	}
-
 
121
 
-
 
122
	/*
-
 
123
	public String getHeaderSnippet(){
103
    String getUrl(){
124
		return htmlSnippets.get("HEADER");
104
    	return this.redirectUrl;
125
	}
-
 
126
 
-
 
127
	public String getMainMenuSnippet(){
-
 
128
		return htmlSnippets.get("MAIN_MENU");
-
 
129
	}
-
 
130
	
-
 
131
	public String getSearchBarSnippet(){
-
 
132
		return htmlSnippets.get("SEARCH_BAR");
-
 
133
	}
-
 
134
    		
105
    }
135
 
-
 
136
	public String getCustomerServiceSnippet(){
-
 
137
		return htmlSnippets.get("CUSTOMER_SERVICE");
-
 
138
	}
-
 
139
	*/
106
    
140
	
-
 
141
	public String getLoginHeaderSnippet(){
107
	public String getLoginHeaderSnippet(){
142
		return htmlSnippets.get("LOGIN_HEADER");
108
		return htmlSnippets.get("LOGIN_HEADER");
143
	}
109
	}
144
	
110
	
145
	public String getLoginFormSnippet(){
111
	public String getLoginFormSnippet(){
146
		return htmlSnippets.get("LOGIN_FORM");
112
		return htmlSnippets.get("LOGIN_FORM");
147
	}
113
	}
148
 
114
 
149
	/*
-
 
150
	public String getRecommendationsSnippet(){
-
 
151
		return htmlSnippets.get("RECOMMENDATIONS");
-
 
152
	}
-
 
153
 
-
 
154
	public String getBrowseHistorySnippet(){
-
 
155
		return htmlSnippets.get("BROWSE_HISTORY");
-
 
156
	}
-
 
157
			
-
 
158
	public String getFooterSnippet(){
-
 
159
		return htmlSnippets.get("FOOTER");
-
 
160
	}
-
 
161
	 */
-
 
162
	public String getJsFileSnippet(){
-
 
163
		return htmlSnippets.get("JS_FILES");
-
 
164
	}
-
 
165
	
-
 
166
	public String getCssFileSnippet(){
-
 
167
		return htmlSnippets.get("CSS_FILES");
-
 
168
	}
-
 
169
 
-
 
170
}
115
}