1. 添加新的正式环境的secret配置信息。
2. 动态回调地址,如果是钉钉应用则用对应的回调地址。 3. 高频错误评查点改成显示出错次数。 4. 添加开关的通用组件,评查点列表方便修改状态。
This commit is contained in:
+29
-2
@@ -3,7 +3,7 @@ import { useEffect } from "react";
|
||||
import { useSearchParams } from "@remix-run/react";
|
||||
import { createUserSession, sessionStorage } from "~/api/login/auth.server";
|
||||
import { OAuthClient } from "~/api/login/oauth-client";
|
||||
import { getServerOAuthConfigRuntime } from "~/config/oauth-secret.server";
|
||||
import { getServerOAuthConfigRuntime, getPortOAuthConfig } from "~/config/oauth-secret.server";
|
||||
import { loginWithOAuth, type LoginRequest } from "~/api/login/login-client";
|
||||
import { isMobileDevice, MOBILE_CHAT_PATH } from "~/utils/mobile-detect.server";
|
||||
|
||||
@@ -106,9 +106,36 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
|
||||
console.log("✅ OAuth2.0回调参数验证通过");
|
||||
|
||||
// 🔑 判断是否从钉钉登录:检查 remote-user header
|
||||
const remoteUser = request.headers.get("remote-user");
|
||||
const isDingTalkLogin = remoteUser !== null;
|
||||
|
||||
console.log("🔧 [Callback] remote-user 检测:", {
|
||||
remoteUser: remoteUser,
|
||||
isDingTalkLogin: isDingTalkLogin,
|
||||
loginType: isDingTalkLogin ? '钉钉Web登录' : '内网Web登录'
|
||||
});
|
||||
|
||||
// 声明在 try 外部,以便在 catch 中访问
|
||||
let tokenResponse = null;
|
||||
const oauthClient = new OAuthClient(getServerOAuthConfigRuntime());
|
||||
|
||||
// 获取端口特定的OAuth配置(包含钉钉回调地址)
|
||||
const portOAuthConfig = getPortOAuthConfig(port);
|
||||
const oauthClient = new OAuthClient(portOAuthConfig);
|
||||
|
||||
// 🔑 根据登录类型设置回调地址
|
||||
if (isDingTalkLogin) {
|
||||
// 钉钉登录:使用钉钉回调地址
|
||||
if (portOAuthConfig.dingtalkRedirectUri) {
|
||||
oauthClient.setRedirectUri(portOAuthConfig.dingtalkRedirectUri);
|
||||
console.log("🔧 [Callback] 使用钉钉回调地址:", portOAuthConfig.dingtalkRedirectUri);
|
||||
} else {
|
||||
console.warn("⚠️ [Callback] 钉钉登录但未配置钉钉回调地址,使用默认内网地址");
|
||||
}
|
||||
} else {
|
||||
// 内网登录:使用默认内网回调地址
|
||||
console.log("🔧 [Callback] 使用内网回调地址:", portOAuthConfig.redirectUri);
|
||||
}
|
||||
|
||||
try {
|
||||
console.log("🔧 开始处理OAuth2.0回调");
|
||||
|
||||
Reference in New Issue
Block a user