Subversion Repositories SmartDukaan

Rev

Rev 21561 | Rev 21574 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21561 ashik.ali 1
package com.spice.profitmandi.web.controller;
21555 kshitij.so 2
 
21561 ashik.ali 3
import javax.servlet.http.HttpServletRequest;
4
 
21568 ashik.ali 5
import org.hibernate.tool.schema.extract.internal.ForeignKeyInformationImpl;
6
import org.slf4j.Logger;
7
import org.slf4j.LoggerFactory;
21561 ashik.ali 8
import org.springframework.beans.factory.annotation.Autowired;
21555 kshitij.so 9
import org.springframework.stereotype.Controller;
10
import org.springframework.ui.ModelMap;
11
import org.springframework.web.bind.annotation.ModelAttribute;
12
import org.springframework.web.bind.annotation.RequestMapping;
13
import org.springframework.web.bind.annotation.RequestMethod;
21561 ashik.ali 14
import org.springframework.web.bind.annotation.RequestParam;
21555 kshitij.so 15
 
21561 ashik.ali 16
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
17
import com.spice.profitmandi.common.model.ProfitMandiConstants;
18
import com.spice.profitmandi.web.model.FofoDetails;
19
import com.spice.profitmandi.web.util.GoogleLoginUtil;
20
 
21555 kshitij.so 21
@Controller
22
public class LoginController {
23
 
21568 ashik.ali 24
	private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
25
 
21561 ashik.ali 26
	@Autowired
27
	GoogleLoginUtil googleLoginUtil;
28
 
21555 kshitij.so 29
	@RequestMapping(value = "/login", method = RequestMethod.GET)
21568 ashik.ali 30
	public String loginPage(@ModelAttribute("model") ModelMap model) {
21555 kshitij.so 31
		return "login";
32
	}
33
 
34
	@RequestMapping(value = "/login", method = RequestMethod.POST)
21568 ashik.ali 35
	public String login(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.TOKEN) String token){
21561 ashik.ali 36
		try{
37
			FofoDetails fofoDetails = googleLoginUtil.getFofoDetail(token);
38
			request.getSession().setAttribute(ProfitMandiConstants.FOFO_DETAILS, fofoDetails);
39
			return "redirect: dashboard";
40
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
21568 ashik.ali 41
			LOGGER.error("Error : ", profitMandiBusinessException);
21561 ashik.ali 42
			return "redirect: error";
43
		}
21555 kshitij.so 44
	}
45
}