|
@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
|
|
@Controller
|
|
@Controller
|
|
@RequestMapping("/sign")
|
|
@RequestMapping("/sign")
|
|
@@ -55,14 +56,19 @@ public class SignController {
|
|
* http://localhost:7001/simulation/oauth/client/entry?ticket=1001
|
|
* http://localhost:7001/simulation/oauth/client/entry?ticket=1001
|
|
*/
|
|
*/
|
|
@RequestMapping("/entry")
|
|
@RequestMapping("/entry")
|
|
|
|
+ @SneakyThrows
|
|
public String entry(@RequestParam("ticket") String ticket) {
|
|
public String entry(@RequestParam("ticket") String ticket) {
|
|
- log.info(oauthParameter.toString());
|
|
|
|
|
|
+ log.info("------- 接收到的 ticket 为:" + ticket);
|
|
|
|
+ String encode = URLEncoder.encode(ticket, "utf-8");
|
|
|
|
+ log.info("------- ticket 编码之后为:" + encode);
|
|
|
|
+
|
|
String zoogooyAuthorizeUrl = oauthParameter.getZoogooyAuthorizeUri() +
|
|
String zoogooyAuthorizeUrl = oauthParameter.getZoogooyAuthorizeUri() +
|
|
"?appid=" + oauthParameter.getZoogooyAppid() +
|
|
"?appid=" + oauthParameter.getZoogooyAppid() +
|
|
"&redirect_uri=" + oauthParameter.getZoogooyRedirectUri() +
|
|
"&redirect_uri=" + oauthParameter.getZoogooyRedirectUri() +
|
|
- "&ticket=" + ticket +
|
|
|
|
|
|
+ "&ticket=" + encode +
|
|
"&response_type=code" +
|
|
"&response_type=code" +
|
|
"&scope=snsapi_userinfo";
|
|
"&scope=snsapi_userinfo";
|
|
|
|
+ log.info("------- 需要访问的授权地址为:" + zoogooyAuthorizeUrl);
|
|
return "redirect:" + zoogooyAuthorizeUrl;
|
|
return "redirect:" + zoogooyAuthorizeUrl;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -155,7 +161,7 @@ public class SignController {
|
|
//1 使用 username 查询数据库,是否已在仿真平台存在该用户
|
|
//1 使用 username 查询数据库,是否已在仿真平台存在该用户
|
|
String username = signSingleParameter.getUsername();
|
|
String username = signSingleParameter.getUsername();
|
|
String password = signSingleParameter.getPassword();
|
|
String password = signSingleParameter.getPassword();
|
|
- log.info("登录参数为:"+signSingleParameter);
|
|
|
|
|
|
+ log.info("登录参数为:" + signSingleParameter);
|
|
UserPO oldUser = userMapper.selectByUsername(username);
|
|
UserPO oldUser = userMapper.selectByUsername(username);
|
|
if (oldUser == null) { //2-1 仿真平台不存在用户,直接创建新的
|
|
if (oldUser == null) { //2-1 仿真平台不存在用户,直接创建新的
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "不存在该用户!");
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "不存在该用户!");
|