|
@@ -61,7 +61,7 @@ public class OAuthController {
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/authorize", method = RequestMethod.GET)
|
|
|
- public @ResponseBody ModelAndView Authorize(@RequestHeader HttpHeaders headers,
|
|
|
+ public ModelAndView Authorize(@RequestHeader HttpHeaders headers,
|
|
|
@RequestParam(value = "response_type", required = true) String responseType,
|
|
|
@RequestParam(value = "client_id", required = true) String clientId,
|
|
|
@RequestParam(value = "state", required = true) String state, @RequestParam(value = "scope") String scope,
|
|
@@ -109,7 +109,7 @@ public class OAuthController {
|
|
|
return mav;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/user/info/submit", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/user/info/submit", method = RequestMethod.GET)
|
|
|
public ModelAndView sendCode(HttpSession httpSession, HttpServletResponse httpResponse,
|
|
|
@RequestParam(value = "complex", required = true) String complex,
|
|
|
@RequestParam(value = "dong", required = true) String dong,
|
|
@@ -137,12 +137,22 @@ public class OAuthController {
|
|
|
logger.info("*[wallpadCode]");
|
|
|
logger.info("*code: " + wallpadCode);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ String homeInfo = complex + "/" + dong + "/" + ho;
|
|
|
+
|
|
|
+
|
|
|
+ ValueOperations<String, Object> vop = redisTemplate.opsForValue();
|
|
|
+ Duration d = Duration.ofSeconds(180);
|
|
|
+
|
|
|
+ while (!vop.setIfAbsent(wallpadCode, homeInfo, d)) {
|
|
|
+ wallpadCode = "";
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
+ wallpadCode += Integer.toString(generator.nextInt(10));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.info("*[redis]");
|
|
|
+ logger.info("*(key,value): (" + wallpadCode + "," + homeInfo + ")");
|
|
|
|
|
|
|
|
|
WallpadCode body = new WallpadCode(dong, ho, wallpadCode);
|
|
@@ -163,15 +173,6 @@ public class OAuthController {
|
|
|
new ResponseStatusException(HttpStatus.BAD_REQUEST, ERROR.INVALID_HOMEINFO);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- String homeInfo = complex + "/" + dong + "/" + ho;
|
|
|
-
|
|
|
- ValueOperations<String, Object> vop = redisTemplate.opsForValue();
|
|
|
- Duration d = Duration.ofSeconds(180);
|
|
|
- vop.set(wallpadCode, homeInfo, d);
|
|
|
- logger.info("*[redis]");
|
|
|
- logger.info("*(key,value): (" + wallpadCode + "," + homeInfo + ")");
|
|
|
-
|
|
|
ModelAndView mav = new ModelAndView();
|
|
|
mav.setViewName("InsertCode");
|
|
|
return mav;
|
|
@@ -227,7 +228,13 @@ public class OAuthController {
|
|
|
logger.info("*1. code: " + code);
|
|
|
|
|
|
Duration d = Duration.ofSeconds(180);
|
|
|
- vop.set(code, homeInfo, d);
|
|
|
+
|
|
|
+ while (!vop.setIfAbsent(code, homeInfo, d)) {
|
|
|
+ code = "";
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ code += String.valueOf((char) ((int) (rnd.nextInt(26)) + 65));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
String redirectUri = (String) httpSession.getAttribute("redirectUri");
|
|
|
redirectUri += "?state=" + httpSession.getAttribute("state");
|
|
@@ -240,7 +247,7 @@ public class OAuthController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/token", method = RequestMethod.GET, produces = "application/json")
|
|
|
+ @RequestMapping(value = "/token", method = RequestMethod.POST, produces = "application/json")
|
|
|
public @ResponseBody Token Token(@RequestParam(value = "grant_type", required = true) String grantType,
|
|
|
@RequestParam(value = "code", required = false) String code,
|
|
|
@RequestParam(value = "refresh_token", required = false) String refreshToken, HttpSession httpSession)
|