Subversion Repositories SmartDukaan

Rev

Rev 2200 | Rev 2419 | 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
 
2263 vikas 3
import in.shop2020.datalogger.EventType;
1957 vikas 4
import in.shop2020.serving.utils.DataLogger;
458 rajveer 5
import in.shop2020.thrift.clients.UserContextServiceClient;
6
 
7
import java.util.Date;
8
import javax.servlet.http.Cookie;
9
 
10
import org.apache.struts2.convention.annotation.Result;
11
import org.apache.struts2.convention.annotation.Results;
12
 
13
/**
14
 * @author rajveer
15
 *
16
 */
17
@Results({
18
    @Result(name="success", type="redirectAction", 
823 vikas 19
    		params = {"actionName" , "home"})
458 rajveer 20
})
21
 
22
public class LogoutController extends BaseController {
23
 
24
 
25
	/**
26
	 * 
27
	 */
650 rajveer 28
	private static final long serialVersionUID = 1L;
29
	/**
30
	 * 
31
	 */
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");
1713 vikas 44
			uidCookie.setDomain(domainName);
45
			uidCookie.setPath("/");
1658 vikas 46
			uidCookie.setValue("");
555 chandransh 47
			uidCookie.setMaxAge(0);
48
	    	this.response.addCookie(uidCookie);
458 rajveer 49
		}	
2263 vikas 50
		DataLogger.logData(EventType.LOGOUT.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail());
458 rajveer 51
		return "success";
52
 
53
    }
54
 
55
 
56
    public boolean logoutUser(long userId) throws Exception{
555 chandransh 57
		UserContextServiceClient userContextServiceClient =new UserContextServiceClient();
58
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
458 rajveer 59
 
60
		userClient.setUserAsLoggedOut(userId, (new Date()).getTime());
61
 
62
    	return true;
63
    }
64
 
65
}