Subversion Repositories SmartDukaan

Rev

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

Rev 28256 Rev 30299
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.lang.reflect.Type;
-
 
4
import java.time.LocalDateTime;
-
 
5
import java.util.ArrayList;
-
 
6
import java.util.Arrays;
-
 
7
import java.util.HashMap;
-
 
8
import java.util.HashSet;
-
 
9
import java.util.List;
-
 
10
import java.util.Map;
-
 
11
import java.util.Set;
-
 
12
import java.util.stream.Collectors;
-
 
13
 
-
 
14
import javax.servlet.http.Cookie;
-
 
15
import javax.servlet.http.HttpServletRequest;
-
 
16
import javax.servlet.http.HttpServletResponse;
-
 
17
import javax.transaction.Transactional;
-
 
18
 
-
 
19
import org.apache.http.NameValuePair;
-
 
20
import org.apache.http.client.utils.URLEncodedUtils;
-
 
21
import org.apache.http.message.BasicNameValuePair;
-
 
22
import org.apache.logging.log4j.LogManager;
-
 
23
import org.apache.logging.log4j.Logger;
-
 
24
import org.springframework.beans.factory.annotation.Autowired;
-
 
25
import org.springframework.beans.factory.annotation.Value;
-
 
26
import org.springframework.stereotype.Controller;
-
 
27
import org.springframework.ui.Model;
-
 
28
import org.springframework.ui.ModelMap;
-
 
29
import org.springframework.web.bind.annotation.ModelAttribute;
-
 
30
import org.springframework.web.bind.annotation.PostMapping;
-
 
31
import org.springframework.web.bind.annotation.RequestBody;
-
 
32
import org.springframework.web.bind.annotation.RequestMapping;
-
 
33
import org.springframework.web.bind.annotation.RequestMethod;
-
 
34
import org.springframework.web.bind.annotation.RequestParam;
-
 
35
 
-
 
36
import com.google.gson.Gson;
3
import com.google.gson.Gson;
37
import com.google.gson.reflect.TypeToken;
4
import com.google.gson.reflect.TypeToken;
38
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
39
import com.spice.profitmandi.common.model.Location;
6
import com.spice.profitmandi.common.model.Location;
40
import com.spice.profitmandi.common.model.ProfitMandiConstants;
7
import com.spice.profitmandi.common.model.ProfitMandiConstants;
41
import com.spice.profitmandi.common.model.ProfitMandiResponse;
8
import com.spice.profitmandi.common.model.ProfitMandiResponse;
42
import com.spice.profitmandi.common.web.client.RestClient;
9
import com.spice.profitmandi.common.web.client.RestClient;
43
import com.spice.profitmandi.dao.entity.auth.AuthUser;
10
import com.spice.profitmandi.dao.entity.auth.AuthUser;
44
import com.spice.profitmandi.dao.entity.dtr.Retailer;
-
 
45
import com.spice.profitmandi.dao.entity.dtr.Role;
11
import com.spice.profitmandi.dao.entity.dtr.*;
46
import com.spice.profitmandi.dao.entity.dtr.User;
-
 
47
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
-
 
48
import com.spice.profitmandi.dao.entity.dtr.UserRole;
-
 
49
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
12
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
50
import com.spice.profitmandi.dao.entity.user.Device;
13
import com.spice.profitmandi.dao.entity.user.Device;
51
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
14
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
52
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
15
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
53
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
16
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
54
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
17
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
55
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
-
 
56
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
-
 
57
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
18
import com.spice.profitmandi.dao.repository.dtr.*;
58
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
-
 
59
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
-
 
60
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
-
 
61
import com.spice.profitmandi.service.AuthService;
19
import com.spice.profitmandi.service.AuthService;
62
import com.spice.profitmandi.service.authentication.RoleManager;
20
import com.spice.profitmandi.service.authentication.RoleManager;
63
import com.spice.profitmandi.service.user.RetailerService;
21
import com.spice.profitmandi.service.user.RetailerService;
64
import com.spice.profitmandi.web.model.LoginDetails;
22
import com.spice.profitmandi.web.model.LoginDetails;
65
import com.spice.profitmandi.web.util.CookiesProcessor;
23
import com.spice.profitmandi.web.util.CookiesProcessor;
66
import com.spice.profitmandi.web.util.GoogleTokenUtil;
24
import com.spice.profitmandi.web.util.GoogleTokenUtil;
67
import com.spice.profitmandi.web.util.MVCResponseSender;
25
import com.spice.profitmandi.web.util.MVCResponseSender;
-
 
26
import org.apache.http.NameValuePair;
-
 
27
import org.apache.http.client.utils.URLEncodedUtils;
-
 
28
import org.apache.http.message.BasicNameValuePair;
-
 
29
import org.apache.logging.log4j.LogManager;
-
 
30
import org.apache.logging.log4j.Logger;
-
 
31
import org.springframework.beans.factory.annotation.Autowired;
-
 
32
import org.springframework.beans.factory.annotation.Value;
-
 
33
import org.springframework.stereotype.Controller;
-
 
34
import org.springframework.ui.Model;
-
 
35
import org.springframework.ui.ModelMap;
-
 
36
import org.springframework.web.bind.annotation.*;
-
 
37
 
-
 
38
import javax.servlet.http.Cookie;
-
 
39
import javax.servlet.http.HttpServletRequest;
-
 
40
import javax.servlet.http.HttpServletResponse;
-
 
41
import javax.transaction.Transactional;
-
 
42
import java.lang.reflect.Type;
-
 
43
import java.time.LocalDateTime;
-
 
44
import java.util.*;
-
 
45
import java.util.stream.Collectors;
68
 
46
 
69
@Controller
47
@Controller
70
@Transactional
48
@Transactional
71
public class LoginController {
49
public class LoginController {
72
 
50
 
Line 172... Line 150...
172
			throws Exception {
150
			throws Exception {
173
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
151
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
174
		if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
152
		if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
175
			if (emailId.equals("")) {
153
			if (emailId.equals("")) {
176
				model.addAttribute("authToken", getToken(fofoDetails.getEmailId()));
154
				model.addAttribute("authToken", getToken(fofoDetails.getEmailId()));
-
 
155
				model.addAttribute("androidId", getAndroidId(fofoDetails.getEmailId()));
177
			} else {
156
			} else {
178
				model.addAttribute("authToken", getToken(emailId));
157
				model.addAttribute("authToken", getToken(emailId));
179
				model.addAttribute("androidId", getAndroidId(emailId));
158
				model.addAttribute("androidId", getAndroidId(emailId));
180
			}
159
			}
181
		} else {
160
		} else {