Subversion Repositories SmartDukaan

Rev

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

Rev 21598 Rev 21615
Line 6... Line 6...
6
 
6
 
7
import org.slf4j.Logger;
7
import org.slf4j.Logger;
8
import org.slf4j.LoggerFactory;
8
import org.slf4j.LoggerFactory;
9
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.stereotype.Controller;
10
import org.springframework.stereotype.Controller;
-
 
11
import org.springframework.ui.Model;
11
import org.springframework.ui.ModelMap;
12
import org.springframework.ui.ModelMap;
12
import org.springframework.web.bind.annotation.ModelAttribute;
13
import org.springframework.web.bind.annotation.ModelAttribute;
13
import org.springframework.web.bind.annotation.RequestMapping;
14
import org.springframework.web.bind.annotation.RequestMapping;
14
import org.springframework.web.bind.annotation.RequestMethod;
15
import org.springframework.web.bind.annotation.RequestMethod;
15
import org.springframework.web.bind.annotation.RequestParam;
16
import org.springframework.web.bind.annotation.RequestParam;
Line 39... Line 40...
39
	public String loginPage(HttpServletRequest request, @ModelAttribute("model") ModelMap model) throws Exception{
40
	public String loginPage(HttpServletRequest request, @ModelAttribute("model") ModelMap model) throws Exception{
40
		try{
41
		try{
41
			cookiesFetcher.getCookiesObject(request);
42
			cookiesFetcher.getCookiesObject(request);
42
			LOGGER.info("Request session is already exist, should be redirect to /dashboard");
43
			LOGGER.info("Request session is already exist, should be redirect to /dashboard");
43
			return "redirect:/dashboard";
44
			return "redirect:/dashboard";
44
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
45
		}catch(Exception | ProfitMandiBusinessException profitMandiBusinessException){
45
			return "login";
46
			return "login";
46
		}
47
		}
47
	}
48
	}
48
	
49
	
49
	@RequestMapping(value = "/login", method = RequestMethod.POST)
50
	@RequestMapping(value = "/login", method = RequestMethod.POST)
50
	public String login(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.TOKEN) String token, @ModelAttribute ModelMap model) throws Exception{
51
	public String login(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.TOKEN) String token, Model model) throws Exception{
51
		try{
52
		try{
52
			FofoDetails fofoDetails = googleLoginUtil.getFofoDetail(token);
53
			FofoDetails fofoDetails = googleLoginUtil.getFofoDetail(token);
53
			Cookie cookieFofoId = new Cookie(ProfitMandiConstants.FOFO_ID, String.valueOf(fofoDetails.getFofoId()));
54
			Cookie cookieFofoId = new Cookie(ProfitMandiConstants.FOFO_ID, String.valueOf(fofoDetails.getFofoId()));
54
			cookieFofoId.setDomain(request.getServerName());
55
			cookieFofoId.setDomain("localhost");
55
			cookieFofoId.setMaxAge(30);
56
			cookieFofoId.setPath(request.getContextPath());
56
			Cookie cookieEmailId = new Cookie(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId());
57
			Cookie cookieEmailId = new Cookie(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId());
57
			cookieEmailId.setDomain(request.getServerName());
58
			cookieEmailId.setDomain("localhost");
58
			cookieEmailId.setMaxAge(30);
59
			cookieEmailId.setPath(request.getContextPath());
59
			response.addCookie(cookieFofoId);
60
			response.addCookie(cookieFofoId);
60
			response.addCookie(cookieEmailId);
61
			response.addCookie(cookieEmailId);
61
			LOGGER.info("Requested token email_id is valid, user login to system, shoud be redirect to /dashboard");
62
			LOGGER.info("Requested token email_id is valid, user login to system, shoud be redirect to /dashboard");
62
			model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_OK_1002", true, "/dashboard"));
63
			model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_OK_1002", true, "/profitmandi-fofo/dashboard"));
63
			return "response";
64
			return "response";
-
 
65
//			return mvcResponseSender.createResponseString("RTLR_OK_1002", true, "/profitmandi-fofo/dashboard");
64
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
66
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
65
			LOGGER.error("Error : ", profitMandiBusinessException);
67
			LOGGER.error("Error : ", profitMandiBusinessException);
66
			model.addAttribute("loginResponse", mvcResponseSender.createResponseString(profitMandiBusinessException.getCode(), false, "/error"));
68
			model.addAttribute("loginResponse", mvcResponseSender.createResponseString(profitMandiBusinessException.getCode(), false, "/error"));
67
			return "response";
69
			return "response";
68
		}
70
		}