Subversion Repositories SmartDukaan

Rev

Rev 2907 | Rev 3126 | 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;
2911 rajveer 4
import in.shop2020.serving.services.UserSessionInfo;
458 rajveer 5
import in.shop2020.thrift.clients.UserContextServiceClient;
2511 vikas 6
import in.shop2020.utils.DataLogger;
458 rajveer 7
 
8
import java.util.Date;
2419 vikas 9
 
458 rajveer 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());
2911 rajveer 42
			//Clean the old userinfo
43
			userinfo = new UserSessionInfo();
2907 rajveer 44
			clearUserCookies();
458 rajveer 45
		}	
2419 vikas 46
		DataLogger.logData(EventType.LOGOUT, session.getId(), userinfo.getUserId(), userinfo.getEmail());
458 rajveer 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
    	return true;
58
    }
59
 
60
}