Commit ca782b17 authored by 曹雷's avatar 曹雷

merge

parents 38844234 085f5fd6
...@@ -38,7 +38,7 @@ import java.util.function.Function; ...@@ -38,7 +38,7 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Controller @Controller
@RequestMapping("auth") @RequestMapping("/")
public class AuthController { public class AuthController {
Logger logger = Logger.getLogger(AuthController.class); Logger logger = Logger.getLogger(AuthController.class);
...@@ -53,76 +53,22 @@ public class AuthController { ...@@ -53,76 +53,22 @@ public class AuthController {
private AuthLogService authLogService; private AuthLogService authLogService;
// @RequestMapping("index")
// public ModelAndView index(HttpServletRequest request, HttpServletResponse response) { @RequestMapping(value = {"","auth","auth/index"})
// ModelAndView modelAndView = new ModelAndView();
// modelAndView.setViewName("index2");
// Map<String, ClientItem> clientItemMap = oauthClient.getClients().stream().collect(Collectors.toMap(ClientItem::getClientId, Function.identity()));
// try {
// String clientId = request.getParameter("client_id");
// String returnUrl = request.getParameter("redirect_uri");
// ClientItem clientItem = clientItemMap.get(clientId);
// AuthLog authLog = new AuthLog();
// authLog.setLogType(LogType.login);
// if (null == clientItem) {
// modelAndView.setViewName("error");
// modelAndView.addObject("message", "client_id为空或者不正确");
// return modelAndView;
// }
// authLog.setClientId(clientId);
// authLog.setAuthSource(clientItem.getClientName());
// String sign = request.getParameter("sign");
// String signOrigin = clientItem.getClientId() + "$$" + clientItem.getClientSecret();
//
// String md5Hex = EncodeUtil.md5(signOrigin);
// if (!Objects.equals(sign, md5Hex)) {
// modelAndView.setViewName("error");
// modelAndView.addObject("message", "请求不合法");
// return modelAndView;
// }
// if (StringUtils.isEmpty(returnUrl)) {
// modelAndView.setViewName("error");
// modelAndView.addObject("message", "登录成功回调地址为空");
// return modelAndView;
// }
// String loginType = request.getParameter("login_type");
// if(StringUtils.isNotEmpty(loginType) && OauthType.getValue(loginType)!=null) {
// OauthConfigItem oauthConfigItem = oauthConfig.getItems().get(OauthType.getValue(loginType).getCode());
// authLog.setFowardUrl(oauthConfigItem.getOauthUrl());
// authLog.setOauthType(OauthType.getValue(loginType).getCode());
// // 阅览室日志分离
// ClientItem item = clientItemMap.get("readingroomClientId");
// authLog.setAuthSource(item.getClientName());
// authLogService.save(authLog);
// response.sendRedirect(generateLoginUrl(returnUrl, OauthType.getValue(loginType).getCode(), authLog.getId()));
// return null;
// } else {
// authLogService.save(authLog);
// String url1 = generateLoginUrl(returnUrl, OauthType.dianjiaoguan.getCode(), authLog.getId());
// modelAndView.addObject("loginUrl1", url1);
// String url2 = generateLoginUrl(returnUrl, OauthType.edenoperation.getCode(), authLog.getId());
// modelAndView.addObject("loginUrl2", url2);
// modelAndView.addObject("logId", authLog.getId());
// }
// } catch (Exception e) {
// e.printStackTrace();
// modelAndView.setViewName("error");
// modelAndView.addObject("message", "未知错误");
// }
// return modelAndView;
// }
@RequestMapping("index")
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) { public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView(); ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("ds"); modelAndView.setViewName("ds");
Map<String, ClientItem> clientItemMap = oauthClient.getClients().stream().collect(Collectors.toMap(ClientItem::getClientId, Function.identity())); Map<String, ClientItem> clientItemMap = oauthClient.getClients().stream().collect(Collectors.toMap(ClientItem::getClientId, Function.identity()));
try { try {
String clientId = request.getParameter("client_id"); String clientId = request.getParameter("client_id");
String returnUrl = request.getParameter("redirect_uri"); String returnUrl = request.getParameter("redirect_uri");
ClientItem clientItem = clientItemMap.get(clientId);
AuthLog authLog = new AuthLog(); AuthLog authLog = new AuthLog();
authLog.setLogType(LogType.login); authLog.setLogType(LogType.login);
if (StringUtils.isNotEmpty(clientId)){
ClientItem clientItem = clientItemMap.get(clientId);
if (null == clientItem) { if (null == clientItem) {
modelAndView.setViewName("error"); modelAndView.setViewName("error");
modelAndView.addObject("message", "client_id为空或者不正确"); modelAndView.addObject("message", "client_id为空或者不正确");
...@@ -156,6 +102,7 @@ public class AuthController { ...@@ -156,6 +102,7 @@ public class AuthController {
}else { }else {
modelAndView.addObject("loginType",""); modelAndView.addObject("loginType","");
} }
}
authLogService.save(authLog); authLogService.save(authLog);
...@@ -175,7 +122,7 @@ public class AuthController { ...@@ -175,7 +122,7 @@ public class AuthController {
return modelAndView; return modelAndView;
} }
@RequestMapping("tologin") @RequestMapping("auth/tologin")
public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response) { public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView(); ModelAndView modelAndView = new ModelAndView();
String loginUrl = request.getParameter("loginUrl"); String loginUrl = request.getParameter("loginUrl");
...@@ -212,7 +159,7 @@ public class AuthController { ...@@ -212,7 +159,7 @@ public class AuthController {
return modelAndView; return modelAndView;
} }
@RequestMapping("logout") @RequestMapping("auth/logout")
public ModelAndView logout(HttpServletRequest request, HttpServletResponse response) { public ModelAndView logout(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView(); ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("logout"); modelAndView.setViewName("logout");
...@@ -279,7 +226,7 @@ public class AuthController { ...@@ -279,7 +226,7 @@ public class AuthController {
return modelAndView; return modelAndView;
} }
@RequestMapping(value = "loginsuccess", method = RequestMethod.GET) @RequestMapping(value = "auth/loginsuccess", method = RequestMethod.GET)
public ModelAndView loginsuccess(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) { public ModelAndView loginsuccess(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) {
modelAndView.setViewName("loginsuccess"); modelAndView.setViewName("loginsuccess");
String code = request.getParameter("code"); String code = request.getParameter("code");
...@@ -364,7 +311,7 @@ public class AuthController { ...@@ -364,7 +311,7 @@ public class AuthController {
return modelAndView; return modelAndView;
} }
@RequestMapping(value = "idp/loginsuccess") @RequestMapping(value = "auth/idp/loginsuccess")
public ModelAndView idploginsuccess(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) { public ModelAndView idploginsuccess(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) {
modelAndView.setViewName("loginsuccess"); modelAndView.setViewName("loginsuccess");
String code = request.getParameter("code"); String code = request.getParameter("code");
...@@ -431,7 +378,7 @@ public class AuthController { ...@@ -431,7 +378,7 @@ public class AuthController {
} }
@RequestMapping(value = "logoutsuccess", method = RequestMethod.GET) @RequestMapping(value = "auth/logoutsuccess", method = RequestMethod.GET)
public ModelAndView loginoutsuccess(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) throws IOException { public ModelAndView loginoutsuccess(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) throws IOException {
String returnUrl = request.getParameter("return_url"); String returnUrl = request.getParameter("return_url");
if(StringUtils.isNotEmpty(returnUrl)){ if(StringUtils.isNotEmpty(returnUrl)){
...@@ -591,7 +538,7 @@ public class AuthController { ...@@ -591,7 +538,7 @@ public class AuthController {
return newUrl; return newUrl;
} }
@RequestMapping("shauth") @RequestMapping("auth/shauth")
public ModelAndView chineseallLogin(HttpServletRequest request, HttpServletResponse response) { public ModelAndView chineseallLogin(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView(); ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("toward"); modelAndView.setViewName("toward");
...@@ -637,7 +584,7 @@ public class AuthController { ...@@ -637,7 +584,7 @@ public class AuthController {
return modelAndView; return modelAndView;
} }
@RequestMapping("shlogout") @RequestMapping("auth/shlogout")
public ModelAndView shLogout(HttpServletRequest request, HttpServletResponse response) { public ModelAndView shLogout(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView(); ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("logout"); modelAndView.setViewName("logout");
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
<!--<script src="../js/vendor/modernizr-2.6.2.min.js"></script>--> <!--<script src="../js/vendor/modernizr-2.6.2.min.js"></script>-->
</head> </head>
<body> <body>
<div> <form th:action="${successPostUrl}" method="post" th:object="${clientDataInfo}">
<!-- <form th:action="${successPostUrl}" method="post" th:object="${clientDataInfo}">
<input type="hidden" th:value="${clientDataInfo.authUserInfo.id}" name="authUserInfo.id"/> <input type="hidden" th:value="${clientDataInfo.authUserInfo.id}" name="authUserInfo.id"/>
<input type="hidden" th:value="${clientDataInfo.authUserInfo.realName}" name="authUserInfo.realName"/> <input type="hidden" th:value="${clientDataInfo.authUserInfo.realName}" name="authUserInfo.realName"/>
<input type="hidden" th:value="${clientDataInfo.authUserInfo.userType}" name="authUserInfo.userType"/> <input type="hidden" th:value="${clientDataInfo.authUserInfo.userType}" name="authUserInfo.userType"/>
...@@ -47,20 +46,11 @@ ...@@ -47,20 +46,11 @@
<input type="hidden" th:value="${clientDataInfo.authUserInfo.teacherSchoolName}" name="authUserInfo.teacherSchoolName"/> <input type="hidden" th:value="${clientDataInfo.authUserInfo.teacherSchoolName}" name="authUserInfo.teacherSchoolName"/>
<input type="hidden" th:value="${clientDataInfo.returnUrl}" name="returnUrl"/> <input type="hidden" th:value="${clientDataInfo.returnUrl}" name="returnUrl"/>
<input type="hidden" th:value="${clientDataInfo.oauthType}" name="oauthType"/> <input type="hidden" th:value="${clientDataInfo.oauthType}" name="oauthType"/>
</form> --> </form>
<p style="font-size: 26px; text-align:center">尊敬的
<span th:value="${clientDataInfo.authUserInfo.realName}"></span>(id:
<span th:value="${clientDataInfo.authUserInfo.id}"></span>),恭喜您通过
<span th:if="${clientDataInfo.authUserInfo.source} == 'edenoperation'">上海数字教材</span>
<span th:if="${clientDataInfo.authUserInfo.source} == 'dianjiaoguan'">上海基础教育</span>
<span th:if="${clientDataInfo.authUserInfo.source} == 'qpjy'">青浦教育</span>
登录成功!
</p>
</div>
<script type="text/javascript"> <script type="text/javascript">
// $(function(){ $(function(){
// $("form").submit(); $("form").submit();
// }) })
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment