Subversion Repositories SmartDukaan

Rev

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

Rev 650 Rev 741
Line 30... Line 30...
30
    @Result(name="failure", type="redirectAction", 
30
    @Result(name="failure", type="redirectAction", 
31
       		params = {"actionName" , "login"}),
31
       		params = {"actionName" , "login"}),
32
    @Result(name="redirect", location="${url}", type="redirect")
32
    @Result(name="redirect", location="${url}", type="redirect")
33
})
33
})
34
 
34
 
35
@InterceptorRefs({
-
 
36
	@InterceptorRef("defaultStack"),
-
 
37
    @InterceptorRef("restDefaultStack")
-
 
38
})
-
 
39
public class LoginController extends BaseController{
35
public class LoginController extends BaseController{
40
		  
36
		  
41
 
37
 
42
	private static Log log = LogFactory.getLog(LoginController.class);
38
	private static Log log = LogFactory.getLog(LoginController.class);
43
	
39
	
Line 48... Line 44...
48
	}
44
	}
49
 
45
 
50
 
46
 
51
    public String index() throws SecurityException, IOException {
47
    public String index() throws SecurityException, IOException {
52
    	htmlSnippets.put("LOGIN_HEADER", pageLoader.getLoginHeaderHtml());
48
    	htmlSnippets.put("LOGIN_HEADER", pageLoader.getLoginHeaderHtml());
53
		htmlSnippets.put("LOGIN_FORM", pageLoader.getLoginFormHtml());
-
 
54
		return "index";
49
		return "index";
55
    }
50
    }
56
 
51
 
57
    public String create() throws SecurityException, Exception {
52
    public String create() throws SecurityException, Exception {
58
    	
53
    	
Line 62... Line 57...
62
    			resetRedirectUrl();
57
    			resetRedirectUrl();
63
    			return "redirect";
58
    			return "redirect";
64
    		}
59
    		}
65
    		return "success";
60
    		return "success";
66
    	}
61
    	}
67
    	else
62
    	else{
-
 
63
    		addActionError("Either email or password is wrong.");
68
    		return "failure";
64
    		return "failure";
-
 
65
    	}
69
    }
66
    }
70
    
67
    
71
    public boolean loginUser(){
68
    private boolean loginUser(){
72
    	try{
69
    	try{
73
	    	String email, password;
70
	    	String email, password;
74
	    	
71
	    	
75
	    	email = this.request.getParameter("email"); 
72
	    	email = this.request.getParameter("email"); 
76
	    	password = this.request.getParameter("password");
73
	    	password = this.request.getParameter("password");
77
	    	
74
	    	
-
 
75
	    	if(email == null || password == null){
-
 
76
	    		return false;
-
 
77
	    	}
-
 
78
	    	
78
	    	UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
79
	    	UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
79
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
80
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
80
			User user = userClient.authenticateUser(email, password);
81
			User user = userClient.authenticateUser(email, password);
81
			userClient.setUserAsLoggedIn(user.getUserId(), (new Date()).getTime());
82
			userClient.setUserAsLoggedIn(user.getUserId(), (new Date()).getTime());
82
	
83
	
Line 105... Line 106...
105
    }
106
    }
106
    
107
    
107
	public String getLoginHeaderSnippet(){
108
	public String getLoginHeaderSnippet(){
108
		return htmlSnippets.get("LOGIN_HEADER");
109
		return htmlSnippets.get("LOGIN_HEADER");
109
	}
110
	}
110
	
-
 
111
	public String getLoginFormSnippet(){
-
 
112
		return htmlSnippets.get("LOGIN_FORM");
-
 
113
	}
-
 
114
 
111
 
115
}
112
}