|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.account.AccountConfig;
|
|
import com.uas.account.AccountConfig;
|
|
|
import com.uas.sso.*;
|
|
import com.uas.sso.*;
|
|
|
|
|
+import com.uas.sso.exception.VisibleError;
|
|
|
import com.uas.sso.foreign.factory.ForeignFactory;
|
|
import com.uas.sso.foreign.factory.ForeignFactory;
|
|
|
import com.uas.sso.foreign.entity.ForeignInfo;
|
|
import com.uas.sso.foreign.entity.ForeignInfo;
|
|
|
import com.uas.sso.foreign.service.ForeignService;
|
|
import com.uas.sso.foreign.service.ForeignService;
|
|
@@ -891,17 +892,13 @@ public class LoginController extends BaseController {
|
|
|
public ModelMap foreignLogin(@RequestParam(defaultValue = "city") String appId, String code, String type) {
|
|
public ModelMap foreignLogin(@RequestParam(defaultValue = "city") String appId, String code, String type) {
|
|
|
// 获取用户信息
|
|
// 获取用户信息
|
|
|
User user = null;
|
|
User user = null;
|
|
|
- ForeignService foreignService = ForeignFactory.getForeignService(type);
|
|
|
|
|
- ForeignInfo foreignInfo = foreignService.getForeignInfoByCode(code);
|
|
|
|
|
-
|
|
|
|
|
- String accessToken = Optional.ofNullable(foreignInfo).map(ForeignInfo::getForeignAccessToken).orElse(null);
|
|
|
|
|
- if (StringUtils.isEmpty(accessToken)) {
|
|
|
|
|
- Long userUU = (Long) request.getSession().getAttribute("userUU");
|
|
|
|
|
- if (userUU == null) {
|
|
|
|
|
- return error("验证信息过期");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Long userUU = (Long) request.getSession().getAttribute("userUU");
|
|
|
|
|
+ if (userUU != null) {
|
|
|
user = new User(userUU);
|
|
user = new User(userUU);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ ForeignService foreignService = ForeignFactory.getForeignService(type);
|
|
|
|
|
+ ForeignInfo foreignInfo = foreignService.getForeignInfoByCode(code);
|
|
|
|
|
+ String accessToken = Optional.ofNullable(foreignInfo).map(ForeignInfo::getForeignAccessToken).orElseThrow(() -> new VisibleError("验证信息过期"));
|
|
|
user = userService.findByForeignId(foreignInfo);
|
|
user = userService.findByForeignId(foreignInfo);
|
|
|
// user为空提示未注册,不为空则放入session绑定用户使用
|
|
// user为空提示未注册,不为空则放入session绑定用户使用
|
|
|
if (user == null) {
|
|
if (user == null) {
|
|
@@ -922,6 +919,6 @@ public class LoginController extends BaseController {
|
|
|
String returnUrl = wr.getParameter("returnUrl");
|
|
String returnUrl = wr.getParameter("returnUrl");
|
|
|
String baseUrl = wr.getParameter("baseUrl");
|
|
String baseUrl = wr.getParameter("baseUrl");
|
|
|
request.getSession().setAttribute("baseUrl", baseUrl);
|
|
request.getSession().setAttribute("baseUrl", baseUrl);
|
|
|
- return success(login(user.getUserUU(), appId, spaceUU, returnUrl)).addAttribute("hasRegister", true);
|
|
|
|
|
|
|
+ return success(login(user.getUserUU(), appId, spaceUU, returnUrl).addAttribute("hasRegister", true));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|