Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

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