Commit ca782b17 authored by 曹雷's avatar 曹雷

merge

parents 38844234 085f5fd6
......@@ -38,7 +38,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
@Controller
@RequestMapping("auth")
@RequestMapping("/")
public class AuthController {
Logger logger = Logger.getLogger(AuthController.class);
......@@ -53,76 +53,22 @@ public class AuthController {
private AuthLogService authLogService;
// @RequestMapping("index")
// public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
// 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")
@RequestMapping(value = {"","auth","auth/index"})
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("ds");
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 (StringUtils.isNotEmpty(clientId)){
ClientItem clientItem = clientItemMap.get(clientId);
if (null == clientItem) {
modelAndView.setViewName("error");
modelAndView.addObject("message", "client_id为空或者不正确");
......@@ -156,6 +102,7 @@ public class AuthController {
}else {
modelAndView.addObject("loginType","");
}
}
authLogService.save(authLog);
......@@ -175,7 +122,7 @@ public class AuthController {
return modelAndView;
}
@RequestMapping("tologin")
@RequestMapping("auth/tologin")
public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
String loginUrl = request.getParameter("loginUrl");
......@@ -212,7 +159,7 @@ public class AuthController {
return modelAndView;
}
@RequestMapping("logout")
@RequestMapping("auth/logout")
public ModelAndView logout(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("logout");
......@@ -279,7 +226,7 @@ public class AuthController {
return modelAndView;
}
@RequestMapping(value = "loginsuccess", method = RequestMethod.GET)
@RequestMapping(value = "auth/loginsuccess", method = RequestMethod.GET)
public ModelAndView loginsuccess(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) {
modelAndView.setViewName("loginsuccess");
String code = request.getParameter("code");
......@@ -364,7 +311,7 @@ public class AuthController {
return modelAndView;
}
@RequestMapping(value = "idp/loginsuccess")
@RequestMapping(value = "auth/idp/loginsuccess")
public ModelAndView idploginsuccess(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) {
modelAndView.setViewName("loginsuccess");
String code = request.getParameter("code");
......@@ -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 {
String returnUrl = request.getParameter("return_url");
if(StringUtils.isNotEmpty(returnUrl)){
......@@ -591,7 +538,7 @@ public class AuthController {
return newUrl;
}
@RequestMapping("shauth")
@RequestMapping("auth/shauth")
public ModelAndView chineseallLogin(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("toward");
......@@ -637,7 +584,7 @@ public class AuthController {
return modelAndView;
}
@RequestMapping("shlogout")
@RequestMapping("auth/shlogout")
public ModelAndView shLogout(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("logout");
......
......@@ -15,8 +15,7 @@
<!--<script src="../js/vendor/modernizr-2.6.2.min.js"></script>-->
</head>
<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.realName}" name="authUserInfo.realName"/>
<input type="hidden" th:value="${clientDataInfo.authUserInfo.userType}" name="authUserInfo.userType"/>
......@@ -47,20 +46,11 @@
<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.oauthType}" name="oauthType"/>
</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>
</form>
<script type="text/javascript">
// $(function(){
// $("form").submit();
// })
$(function(){
$("form").submit();
})
</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