| Line 91... |
Line 91... |
| 91 |
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
91 |
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
| 92 |
public String login(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.TOKEN) String token, Model model) throws Exception{
|
92 |
public String login(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.TOKEN) String token, Model model) throws Exception{
|
| 93 |
LoginDetails fofoDetails = new LoginDetails();
|
93 |
LoginDetails fofoDetails = new LoginDetails();
|
| 94 |
Set<RoleType> roleTypes = new HashSet<>();
|
94 |
Set<RoleType> roleTypes = new HashSet<>();
|
| 95 |
fofoDetails.setRoleTypes(roleTypes);
|
95 |
fofoDetails.setRoleTypes(roleTypes);
|
| 96 |
fofoDetails.setFofo(false);
|
96 |
//fofoDetails.setFofo(false);
|
| 97 |
|
97 |
|
| 98 |
try{
|
98 |
try{
|
| 99 |
//if role is retailer then FOFO_ID is retailerId else it is userid as normal user's wont have retailer id.
|
99 |
//if role is retailer then FOFO_ID is retailerId else it is userid as normal user's wont have retailer id.
|
| 100 |
String emailId = googleTokenUtil.getEmailId(token);
|
100 |
String emailId = googleTokenUtil.getEmailId(token);
|
| 101 |
fofoDetails.setEmailId(emailId);
|
101 |
fofoDetails.setEmailId(emailId);
|
| 102 |
fofoDetails.setFofoId(-1);
|
102 |
fofoDetails.setFofoId(-1);
|
| 103 |
fofoDetails.setFofo(false);
|
103 |
//fofoDetails.setFofo(false);
|
| 104 |
User user = null;
|
104 |
User user = null;
|
| 105 |
try{
|
105 |
try{
|
| 106 |
user = userRepository.selectByEmailId(emailId);
|
106 |
user = userRepository.selectByEmailId(emailId);
|
| 107 |
fofoDetails.setFofoId(user.getId());
|
107 |
fofoDetails.setFofoId(user.getId());
|
| 108 |
try {
|
108 |
try {
|
| Line 112... |
Line 112... |
| 112 |
}
|
112 |
}
|
| 113 |
if(roleTypes.contains(RoleType.RETAILER)) {
|
113 |
if(roleTypes.contains(RoleType.RETAILER)) {
|
| 114 |
UserAccounts userAccounts = userAccountRepository.getUserAccountByType(user.getId(), AccountType.saholic);
|
114 |
UserAccounts userAccounts = userAccountRepository.getUserAccountByType(user.getId(), AccountType.saholic);
|
| 115 |
Retailer retailer = retailerRepository.selectById(Integer.parseInt(userAccounts.getAccount_key()));
|
115 |
Retailer retailer = retailerRepository.selectById(Integer.parseInt(userAccounts.getAccount_key()));
|
| 116 |
fofoDetails.setFofoId(retailer.getId());
|
116 |
fofoDetails.setFofoId(retailer.getId());
|
| 117 |
fofoDetails.setFofo(retailer.isFofo());
|
117 |
//fofoDetails.setFofo(retailer.isFofo());
|
| 118 |
}
|
118 |
}
|
| 119 |
} catch(ProfitMandiBusinessException pmbe) {
|
119 |
} catch(ProfitMandiBusinessException pmbe) {
|
| 120 |
LOGGER.error("Data Inconsistent", pmbe);
|
120 |
LOGGER.error("Data Inconsistent", pmbe);
|
| 121 |
}
|
121 |
}
|
| 122 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
122 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| Line 151... |
Line 151... |
| 151 |
|
151 |
|
| 152 |
Cookie cookieEmailId = new Cookie(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId());
|
152 |
Cookie cookieEmailId = new Cookie(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId());
|
| 153 |
cookieEmailId.setDomain(request.getServerName());
|
153 |
cookieEmailId.setDomain(request.getServerName());
|
| 154 |
cookieEmailId.setPath(request.getContextPath());
|
154 |
cookieEmailId.setPath(request.getContextPath());
|
| 155 |
|
155 |
|
| 156 |
Cookie fofoFlagCookie = new Cookie(ProfitMandiConstants.FOFO_FLAG, Boolean.toString(fofoDetails.isFofo()));
|
- |
|
| 157 |
fofoFlagCookie.setDomain(request.getServerName());
|
- |
|
| 158 |
fofoFlagCookie.setPath(request.getContextPath());
|
- |
|
| 159 |
|
- |
|
| 160 |
response.addCookie(cookieFofoId);
|
156 |
response.addCookie(cookieFofoId);
|
| 161 |
response.addCookie(cookieEmailId);
|
157 |
response.addCookie(cookieEmailId);
|
| 162 |
response.addCookie(cookieRoleNames);
|
158 |
response.addCookie(cookieRoleNames);
|
| 163 |
response.addCookie(fofoFlagCookie);
|
- |
|
| 164 |
}
|
159 |
}
|
| 165 |
|
160 |
|
| 166 |
@RequestMapping(value = "/logout", method = RequestMethod.GET)
|
161 |
@RequestMapping(value = "/logout", method = RequestMethod.GET)
|
| 167 |
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{
|
| 168 |
try{
|
163 |
try{
|