fix: 移除本地token检查,由后端处理授权验证
- 移除 localStorage token 检查,避免与飞书免登并行执行 - 在飞书环境中始终尝试免登,由后端判断登录状态 - 解决'飞书应用配置错误'误导性提示
This commit is contained in:
@@ -21,22 +21,24 @@ export default function Login() {
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [environment, setEnvironment] = useState<'feishu' | 'external' | null>(null)
|
||||
const [showQRCode, setShowQRCode] = useState(false)
|
||||
const [shouldSkipAutoLogin, setShouldSkipAutoLogin] = useState(false) // 防止重复执行免登
|
||||
|
||||
// 检查登录状态
|
||||
useEffect(() => {
|
||||
const token = localStorage.getItem('token')
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const redirect = urlParams.get('redirect')
|
||||
const authCode = urlParams.get('auth_code')
|
||||
|
||||
if (token) {
|
||||
if (redirect) {
|
||||
window.location.href = redirect
|
||||
} else {
|
||||
navigate('/dashboard')
|
||||
}
|
||||
// 如果 URL 中有授权码,直接处理登录
|
||||
if (authCode) {
|
||||
const companyParam = urlParams.get('company')
|
||||
handleFeishuLogin(authCode, companyParam || undefined)
|
||||
return
|
||||
}
|
||||
|
||||
// 不检查本地 token,让后端处理
|
||||
// 继续执行环境检测和免登
|
||||
|
||||
// 监听飞书登录成功事件
|
||||
const handleFeishuLoginSuccess = ((e: any) => {
|
||||
const { user, token } = e.detail
|
||||
|
||||
Reference in New Issue
Block a user