feat(dingdingLogin) - 调整登录
This commit is contained in:
parent
91a79ffb8a
commit
5b3c996e52
@ -273,7 +273,8 @@ public class DangerOperationController {
|
||||
|
||||
// 如果没有配置 AppSecret,则无法进行后续交互
|
||||
if (!StringUtils.hasText(appSecret)) {
|
||||
log.error("【dingtalk】DingTalk AppSecret not configured");
|
||||
log.info("【dingtalk】DingTalk AppSecret not configured");
|
||||
model.addAttribute("isAuthenticated", false);
|
||||
model.addAttribute("authError", "服务端未配置 AppSecret,无法登录");
|
||||
return "form";
|
||||
}
|
||||
@ -297,7 +298,8 @@ public class DangerOperationController {
|
||||
String accessToken = tokenJson.getString("accessToken");
|
||||
|
||||
if (!StringUtils.hasText(accessToken)) {
|
||||
log.error("【dingtalk】Failed to get access token: {}", tokenResponse);
|
||||
log.info("【dingtalk】Failed to get access token: {}", tokenResponse);
|
||||
model.addAttribute("isAuthenticated", false);
|
||||
model.addAttribute("authError", "钉钉登录验证失败: 无法获取 AccessToken");
|
||||
return "form";
|
||||
}
|
||||
@ -315,13 +317,16 @@ public class DangerOperationController {
|
||||
String mobile = userJson.getString("mobile");
|
||||
|
||||
if (!StringUtils.hasText(mobile)) {
|
||||
log.error("【dingtalk】Failed to get user info: {}", userInfoResponse);
|
||||
log.info("【dingtalk】Failed to get user info: {}", userInfoResponse);
|
||||
model.addAttribute("isAuthenticated", false);
|
||||
model.addAttribute("authError", "钉钉登录验证失败: 无法获取用户手机号");
|
||||
return "form";
|
||||
}
|
||||
|
||||
List<ThirdPartyUserDTO> users = RpcExternalUtil.rpcApiResultProcessor(() -> thirdPartySyncApi.getUserInfosByPhone(mobile), "查询用户是否存在", mobile);
|
||||
if (CollectionUtils.isEmpty(users)) {
|
||||
log.info("【dingtalk】Failed to get user info2: {}", JSON.toJSONString(users));
|
||||
model.addAttribute("isAuthenticated", false);
|
||||
model.addAttribute("authError", "用户未授权!");
|
||||
return "form";
|
||||
}
|
||||
@ -341,7 +346,8 @@ public class DangerOperationController {
|
||||
return "form";
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("【dingtalk】DingTalk Callback Error", e);
|
||||
log.info("【dingtalk】DingTalk Callback Error", e);
|
||||
model.addAttribute("isAuthenticated", false);
|
||||
model.addAttribute("authError", "登录过程中发生异常: " + e.getMessage());
|
||||
return "form";
|
||||
}
|
||||
|
||||
@ -148,7 +148,8 @@
|
||||
<!-- 授权验证区域 - 未认证时显示 -->
|
||||
<div th:unless="${isAuthenticated}">
|
||||
<!-- 错误提示 Banner -->
|
||||
<div class="mb-4 bg-red-50 border border-red-200 rounded-lg p-4 flex items-center"
|
||||
<div id="authError"
|
||||
class="mb-4 bg-red-50 border border-red-200 rounded-lg p-4 flex items-center hidden"
|
||||
th:if="${authError != null}">
|
||||
<i class="fa fa-exclamation-circle text-danger text-lg mr-3"></i>
|
||||
<div>
|
||||
@ -587,20 +588,20 @@
|
||||
// 页面加载时检查后端消息
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// 检查流程操作的后端消息(使用 Thymeleaf JS 内联语法)
|
||||
/*[[#{
|
||||
if (${message != null}) {
|
||||
const serverMessage = [[${message}]] || null;
|
||||
if (serverMessage) {
|
||||
operationMessage.classList.remove('hidden');
|
||||
if (${message.startsWith('操作成功')}) {
|
||||
if (serverMessage.includes('成功')) {
|
||||
operationMessage.className = 'mt-4 p-4 rounded-lg bg-green-50 border border-green-200 text-green-700';
|
||||
} else {
|
||||
operationMessage.className = 'mt-4 p-4 rounded-lg bg-red-50 border border-red-200 text-red-700';
|
||||
}
|
||||
operationMessage.innerHTML = '<i class="fa ' + (${message.startsWith('操作成功')} ? 'fa-check-circle' : 'fa-exclamation-circle') + ' mr-2"></i>' + '${message}';
|
||||
const iconClass = serverMessage.includes('成功') ? 'fa-check-circle' : 'fa-exclamation-circle';
|
||||
operationMessage.innerHTML = `<i class="fa ${iconClass} mr-2"></i>${serverMessage}`;
|
||||
}
|
||||
}]]*/
|
||||
|
||||
// 显示授权错误(如果有)
|
||||
if (authError && authError.textContent.trim() !== '') {
|
||||
if (authError && authError.textContent.trim() !== '' && !authError.textContent.includes('${authError}')) {
|
||||
authError.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user