Subversion Repositories SmartDukaan

Rev

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

Rev 22069 Rev 22072
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.io.InputStream;
-
 
4
import java.util.Properties;
3
import java.util.Properties;
5
 
4
 
6
import javax.servlet.http.Cookie;
5
import javax.servlet.http.Cookie;
7
import javax.servlet.http.HttpServletRequest;
6
import javax.servlet.http.HttpServletRequest;
8
import javax.servlet.http.HttpServletResponse;
7
import javax.servlet.http.HttpServletResponse;
9
 
8
 
10
import org.slf4j.Logger;
9
import org.slf4j.Logger;
11
import org.slf4j.LoggerFactory;
10
import org.slf4j.LoggerFactory;
12
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.context.annotation.PropertySource;
-
 
14
import org.springframework.core.io.Resource;
12
import org.springframework.core.io.Resource;
15
import org.springframework.stereotype.Controller;
13
import org.springframework.stereotype.Controller;
16
import org.springframework.transaction.annotation.Transactional;
14
import org.springframework.transaction.annotation.Transactional;
17
import org.springframework.ui.Model;
15
import org.springframework.ui.Model;
18
import org.springframework.ui.ModelMap;
16
import org.springframework.ui.ModelMap;
Line 43... Line 41...
43
	
41
	
44
	@Autowired
42
	@Autowired
45
	CookiesProcessor cookiesProcessor;
43
	CookiesProcessor cookiesProcessor;
46
	
44
	
47
	@RequestMapping(value = "/login", method = RequestMethod.GET)
45
	@RequestMapping(value = "/login", method = RequestMethod.GET)
48
	public String loginPage(HttpServletRequest request, @ModelAttribute("model") ModelMap model) throws Exception{
46
	public String loginPage(HttpServletRequest request, Model model) throws Exception{
49
		try{
47
		try{
50
			cookiesProcessor.getCookiesObject(request);
48
			cookiesProcessor.getCookiesObject(request);
51
			LOGGER.info("Request session is already exist, should be redirect to /dashboard");
49
			LOGGER.info("Request session is already exist, should be redirect to /dashboard");
52
			return "redirect:/dashboard";
50
			return "redirect:/dashboard";
53
		}catch(Exception | ProfitMandiBusinessException profitMandiBusinessException){
51
		}catch(Exception | ProfitMandiBusinessException profitMandiBusinessException){
54
			Resource resource = AppConfig.getResource();
52
			Resource resource = AppConfig.getResource();
55
			Properties properties = new Properties();
53
			Properties properties = new Properties();
56
			properties.load(resource.getInputStream());
54
			properties.load(resource.getInputStream());
57
			model.addAttribute("googleApiKey", properties.getProperty("google.api.key"));
55
			String googleApiKey = properties.getProperty("google.api.key");
-
 
56
			LOGGER.info("Google Api Key {}", googleApiKey);
-
 
57
			model.addAttribute("googleApiKey", googleApiKey);
58
			return "login";
58
			return "login";
59
		}
59
		}
60
	}
60
	}
61
	
61
	
62
	@RequestMapping(value = "/login", method = RequestMethod.POST)
62
	@RequestMapping(value = "/login", method = RequestMethod.POST)