Subversion Repositories SmartDukaan

Rev

Rev 2511 | Rev 2911 | 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;
458 rajveer 4
import in.shop2020.thrift.clients.UserContextServiceClient;
2511 vikas 5
import in.shop2020.utils.DataLogger;
458 rajveer 6
 
7
import java.util.Date;
2419 vikas 8
 
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
	 */
458 rajveer 31
 
32
	public LogoutController() {
33
		super();
34
 
35
	}
36
 
37
    // GET /logout
38
    public String index() throws Exception {
39
		if(this.userinfo.isLoggedIn()){
40
			logoutUser(this.userinfo.getUserId());
2907 rajveer 41
			clearUserCookies();
458 rajveer 42
		}	
2419 vikas 43
		DataLogger.logData(EventType.LOGOUT, session.getId(), userinfo.getUserId(), userinfo.getEmail());
458 rajveer 44
		return "success";
45
 
46
    }
47
 
48
 
49
    public boolean logoutUser(long userId) throws Exception{
555 chandransh 50
		UserContextServiceClient userContextServiceClient =new UserContextServiceClient();
51
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
458 rajveer 52
 
53
		userClient.setUserAsLoggedOut(userId, (new Date()).getTime());
54
 
55
    	return true;
56
    }
57
 
58
}