| 21561 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
| 21555 |
kshitij.so |
2 |
|
| 21561 |
ashik.ali |
3 |
import javax.servlet.http.HttpServletRequest;
|
|
|
4 |
|
|
|
5 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21555 |
kshitij.so |
6 |
import org.springframework.stereotype.Controller;
|
|
|
7 |
import org.springframework.ui.ModelMap;
|
|
|
8 |
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
9 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
10 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21561 |
ashik.ali |
11 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21555 |
kshitij.so |
12 |
|
| 21561 |
ashik.ali |
13 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
14 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
15 |
import com.spice.profitmandi.web.model.FofoDetails;
|
|
|
16 |
import com.spice.profitmandi.web.util.GoogleLoginUtil;
|
|
|
17 |
|
| 21555 |
kshitij.so |
18 |
@Controller
|
|
|
19 |
public class LoginController {
|
|
|
20 |
|
| 21561 |
ashik.ali |
21 |
@Autowired
|
|
|
22 |
GoogleLoginUtil googleLoginUtil;
|
|
|
23 |
|
| 21555 |
kshitij.so |
24 |
@RequestMapping(value = "/login", method = RequestMethod.GET)
|
|
|
25 |
public String init(@ModelAttribute("model") ModelMap model) {
|
|
|
26 |
return "login";
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
| 21561 |
ashik.ali |
30 |
public String indexPage(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.TOKEN) String token){
|
|
|
31 |
try{
|
|
|
32 |
FofoDetails fofoDetails = googleLoginUtil.getFofoDetail(token);
|
|
|
33 |
request.getSession().setAttribute(ProfitMandiConstants.FOFO_DETAILS, fofoDetails);
|
|
|
34 |
return "redirect: dashboard";
|
|
|
35 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
36 |
return "redirect: error";
|
|
|
37 |
}
|
| 21555 |
kshitij.so |
38 |
}
|
|
|
39 |
}
|