Subversion Repositories SmartDukaan

Rev

Rev 2263 | Rev 2511 | 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;
2419 vikas 8
 
458 rajveer 9
import javax.servlet.http.Cookie;
10
 
11
import org.apache.struts2.convention.annotation.Result;
12
import org.apache.struts2.convention.annotation.Results;
13
 
14
/**
15
 * @author rajveer
16
 *
17
 */
18
@Results({
19
    @Result(name="success", type="redirectAction", 
823 vikas 20
    		params = {"actionName" , "home"})
458 rajveer 21
})
22
 
23
public class LogoutController extends BaseController {
24
 
25
 
26
	/**
27
	 * 
28
	 */
650 rajveer 29
	private static final long serialVersionUID = 1L;
30
	/**
31
	 * 
32
	 */
458 rajveer 33
 
34
	public LogoutController() {
35
		super();
36
 
37
	}
38
 
39
    // GET /logout
40
    public String index() throws Exception {
41
		if(this.userinfo.isLoggedIn()){
42
			logoutUser(this.userinfo.getUserId());
43
			this.session.removeAttribute("userinfo");
555 chandransh 44
			Cookie uidCookie = cookiesMap.get("uid");
1713 vikas 45
			uidCookie.setDomain(domainName);
46
			uidCookie.setPath("/");
1658 vikas 47
			uidCookie.setValue("");
555 chandransh 48
			uidCookie.setMaxAge(0);
49
	    	this.response.addCookie(uidCookie);
458 rajveer 50
		}	
2419 vikas 51
		DataLogger.logData(EventType.LOGOUT, session.getId(), userinfo.getUserId(), userinfo.getEmail());
458 rajveer 52
		return "success";
53
 
54
    }
55
 
56
 
57
    public boolean logoutUser(long userId) throws Exception{
555 chandransh 58
		UserContextServiceClient userContextServiceClient =new UserContextServiceClient();
59
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
458 rajveer 60
 
61
		userClient.setUserAsLoggedOut(userId, (new Date()).getTime());
62
 
63
    	return true;
64
    }
65
 
66
}