Subversion Repositories SmartDukaan

Rev

Rev 1034 | Rev 1658 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
458 rajveer 1
package in.shop2020.serving.controllers;
2
 
3
import in.shop2020.thrift.clients.UserContextServiceClient;
4
 
5
import java.util.Date;
6
import javax.servlet.http.Cookie;
7
 
832 rajveer 8
import org.apache.log4j.Logger;
458 rajveer 9
import org.apache.struts2.convention.annotation.Result;
10
import org.apache.struts2.convention.annotation.Results;
11
 
12
/**
13
 * @author rajveer
14
 *
15
 */
16
@Results({
17
    @Result(name="success", type="redirectAction", 
823 vikas 18
    		params = {"actionName" , "home"})
458 rajveer 19
})
20
 
21
public class LogoutController extends BaseController {
22
 
23
 
24
	/**
25
	 * 
26
	 */
650 rajveer 27
	private static final long serialVersionUID = 1L;
28
	/**
29
	 * 
30
	 */
832 rajveer 31
	private static Logger log = Logger.getLogger(Class.class);
458 rajveer 32
 
33
	public LogoutController() {
34
		super();
35
 
36
	}
37
 
38
    // GET /logout
39
    public String index() throws Exception {
40
		if(this.userinfo.isLoggedIn()){
41
			logoutUser(this.userinfo.getUserId());
42
			this.session.removeAttribute("userinfo");
555 chandransh 43
			Cookie uidCookie = cookiesMap.get("uid");
44
			uidCookie.setMaxAge(0);
45
	    	this.response.addCookie(uidCookie);
458 rajveer 46
		}	
47
		return "success";
48
 
49
    }
50
 
51
 
52
    public boolean logoutUser(long userId) throws Exception{
555 chandransh 53
		UserContextServiceClient userContextServiceClient =new UserContextServiceClient();
54
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
458 rajveer 55
 
56
		userClient.setUserAsLoggedOut(userId, (new Date()).getTime());
57
 
58
    	return true;
59
    }
60
 
61
}