Subversion Repositories SmartDukaan

Rev

Rev 22860 | Rev 23173 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22860 Rev 22927
Line 45... Line 45...
45
public class LoginController {
45
public class LoginController {
46
 
46
 
47
	private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
47
	private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
48
	
48
	
49
	@Autowired
49
	@Autowired
50
	GoogleTokenUtil googleTokenUtil;
50
	private GoogleTokenUtil googleTokenUtil;
51
	
51
	
52
	@Autowired
52
	@Autowired
53
	RetailerRepository retailerRepository;
53
	private RetailerRepository retailerRepository;
54
	
54
	
55
	@Autowired
55
	@Autowired
56
	UserRepository userRepository;
56
	private UserRepository userRepository;
57
	
57
	
58
	@Autowired
58
	@Autowired
59
	UserAccountRepository userAccountRepository;
59
	private UserAccountRepository userAccountRepository;
60
	
60
	
61
	@Autowired
61
	@Autowired
62
	UserRoleRepository userRoleRepository;
62
	private UserRoleRepository userRoleRepository;
63
	
63
	
64
	@Autowired
64
	@Autowired
65
	MVCResponseSender mvcResponseSender;
65
	private MVCResponseSender mvcResponseSender;
66
	
66
	
67
	@Autowired
67
	@Autowired
68
	CookiesProcessor cookiesProcessor;
68
	private CookiesProcessor cookiesProcessor;
69
 
69
 
70
	@Value("${google.api.key}")
70
	@Value("${google.api.key}")
71
	private String googleApiKey;
71
	private String googleApiKey;
72
	
72
	
73
	@RequestMapping(value = "/login", method = RequestMethod.GET)
73
	@RequestMapping(value = "/login", method = RequestMethod.GET)
Line 75... Line 75...
75
		LOGGER.info("Context Path is {}", request.getContextPath());
75
		LOGGER.info("Context Path is {}", request.getContextPath());
76
		try{
76
		try{
77
			LoginDetails details = cookiesProcessor.getCookiesObject(request);
77
			LoginDetails details = cookiesProcessor.getCookiesObject(request);
78
			LOGGER.info("Request session is already exist, should be redirect to as per roles assigned");
78
			LOGGER.info("Request session is already exist, should be redirect to as per roles assigned");
79
			return "redirect:" + Utils.getRedictUrlFromLogin(details);
79
			return "redirect:" + Utils.getRedictUrlFromLogin(details);
80
		}catch(Exception | ProfitMandiBusinessException profitMandiBusinessException){
80
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
81
			model.addAttribute("googleApiKey", googleApiKey);
81
			model.addAttribute("googleApiKey", googleApiKey);
82
			model.addAttribute("appContextPath", request.getContextPath());
82
			model.addAttribute("appContextPath", request.getContextPath());
83
			return "login";
83
			return "login";
84
		}
84
		}
85
	}
85
	}
Line 120... Line 120...
120
					LOGGER.error("Data Inconsistent", pmbe);
120
					LOGGER.error("Data Inconsistent", pmbe);
121
				}
121
				}
122
			}catch(ProfitMandiBusinessException profitMandiBusinessException){
122
			}catch(ProfitMandiBusinessException profitMandiBusinessException){
123
				LOGGER.error("User not found with given emailId", profitMandiBusinessException);
123
				LOGGER.error("User not found with given emailId", profitMandiBusinessException);
124
			}
124
			}
125
			addCookiesToResponse(fofoDetails, request, response);
125
			this.addCookiesToResponse(fofoDetails, request, response);
126
			String redirectUrl = Utils.getRedictUrlFromLogin(fofoDetails);
126
			String redirectUrl = Utils.getRedictUrlFromLogin(fofoDetails);
127
			LOGGER.info("Requested token email_id is valid, user login to system, shoud be redirect to {}", redirectUrl);
127
			LOGGER.info("Requested token email_id is valid, user login to system, shoud be redirect to {}", redirectUrl);
128
			
128
			
129
			model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_OK_1002", true, request.getContextPath() + redirectUrl));
129
			model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_OK_1002", true, request.getContextPath() + redirectUrl));
130
			return "response";
130
			return "response";
Line 162... Line 162...
162
	public String logout(HttpServletRequest request, @ModelAttribute("model") ModelMap model, HttpServletResponse response) throws Exception{
162
	public String logout(HttpServletRequest request, @ModelAttribute("model") ModelMap model, HttpServletResponse response) throws Exception{
163
		try{
163
		try{
164
			cookiesProcessor.removeCookies(request, response);
164
			cookiesProcessor.removeCookies(request, response);
165
			LOGGER.info("Logout is successfull, should be redirect to /login");
165
			LOGGER.info("Logout is successfull, should be redirect to /login");
166
			return "redirect:/login";
166
			return "redirect:/login";
167
		}catch(Exception | ProfitMandiBusinessException profitMandiBusinessException){
167
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
168
			LOGGER.info("Error occured while removing requested cookies, should be redirect to /login");
168
			LOGGER.info("Error occured while removing requested cookies, should be redirect to /login");
169
			return "redirect:/login";
169
			return "redirect:/login";
170
		}
170
		}
171
	}
171
	}
172
	
172