diff --git a/chatdesk-ui/app/[locale]/login/page.tsx b/chatdesk-ui/app/[locale]/login/page.tsx index 61a30b9..91e9656 100644 --- a/chatdesk-ui/app/[locale]/login/page.tsx +++ b/chatdesk-ui/app/[locale]/login/page.tsx @@ -31,54 +31,53 @@ export default async function Login({ const supabase = getSupabaseServerClient() - const session = (await supabase.auth.getSession()).data.session + if (searchParams.cleaned !== "true") { + const session = (await supabase.auth.getSession()).data.session - console.log("[login page]Login session============================>", session) + console.log("[login page]Login session============================>", session) - if (session) { - const { data: homeWorkspace, error } = await supabase - .from("workspaces") - .select("*") - .eq("user_id", session.user.id) - .eq("is_home", true) - .maybeSingle(); - - if (!homeWorkspace) { + if (session) { + const { data: homeWorkspace, error } = await supabase + .from("workspaces") + .select("*") + .eq("user_id", session.user.id) + .eq("is_home", true) + .maybeSingle(); + + if (!homeWorkspace) { - // 获取 host 值,根据环境不同决定获取方式 - let hosturl: string | undefined; - if (typeof window !== "undefined") { - // 客户端环境下,使用 window.location.host - console.log("客户端环境:使用 window.location.host 获取 host"); - hosturl = `http://${window.location.host}`; - } else { - // 服务器端环境下,使用 next/headers 获取 host - const hostHeader = headers().get('host'); - if (hostHeader) { - console.log("服务器端环境:使用 headers().get('host') 获取 host", hostHeader); - hosturl = `http://${hostHeader}`; + // 获取 host 值,根据环境不同决定获取方式 + let hosturl: string | undefined; + if (typeof window !== "undefined") { + // 客户端环境下,使用 window.location.host + console.log("客户端环境:使用 window.location.host 获取 host"); + hosturl = `http://${window.location.host}`; } else { - console.log("服务器端环境:没有获取到 host,从环境变量中获取 SUPABASE_URL", process.env.SUPABASE_URL); - hosturl = process.env.SUPABASE_URL; + // 服务器端环境下,使用 next/headers 获取 host + const hostHeader = headers().get('host'); + if (hostHeader) { + console.log("服务器端环境:使用 headers().get('host') 获取 host", hostHeader); + hosturl = `http://${hostHeader}`; + } else { + console.log("服务器端环境:没有获取到 host,从环境变量中获取 SUPABASE_URL", process.env.SUPABASE_URL); + hosturl = process.env.SUPABASE_URL; + } + } + console.log("最终的 hosturl 值:", hosturl); + if (hosturl) { + await fetch(`${hosturl}/api/clearcookies`, { + method: "POST", + }); + } else { + console.error("Host URL is not available"); } - } - console.log("最终的 hosturl 值:", hosturl); - if (hosturl) { - await fetch(`${hosturl}/api/clearcookies`, { - method: "POST", - }); - } else { - console.error("Host URL is not available"); - } - //return redirect(`/${localeString}`); - //return redirect(`/${localeString}/login`); - if (searchParams.cleaned !== "true") { return redirect(`/${locale}/system/clearcookies-then-redirect`) + + } + else{ + return redirect(`/${localeString}/${homeWorkspace!.id}/chat`); } - } - else{ - return redirect(`/${localeString}/${homeWorkspace!.id}/chat`); } } diff --git a/chatdesk-ui/app/[locale]/system/clearcookies-then-redirect/page.tsx b/chatdesk-ui/app/[locale]/system/clearcookies-then-redirect/page.tsx index de96c78..b1243ef 100644 --- a/chatdesk-ui/app/[locale]/system/clearcookies-then-redirect/page.tsx +++ b/chatdesk-ui/app/[locale]/system/clearcookies-then-redirect/page.tsx @@ -13,5 +13,9 @@ export default function ClearCookiesThenRedirect({ params }: { params: { locale: }) }, []) - return null // 什么都不渲染 + return ( +
+ t("login.clearing") +
+ ) } diff --git a/chatdesk-ui/public/locales/bn/translation.json b/chatdesk-ui/public/locales/bn/translation.json index db95db2..0bdbc9f 100644 --- a/chatdesk-ui/public/locales/bn/translation.json +++ b/chatdesk-ui/public/locales/bn/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "পাসওয়ার্ড রিসেট করতে ইমেইল চেক করুন", "signupNotAllowed": "ইমেইল {{email}} দিয়ে সাইন আপ করা অনুমোদিত নয়।", "unexpectedError": "একটি অপ্রত্যাশিত ত্রুটি ঘটেছে", - "invalidCredentials": "অবৈধ ইমেইল বা পাসওয়ার্ড।" + "invalidCredentials": "অবৈধ ইমেইল বা পাসওয়ার্ড।", + "clearing": "লগইন অবস্থা মুছে ফেলা হচ্ছে..." }, "chat": { "defaultChatTitle": "চ্যাট", diff --git a/chatdesk-ui/public/locales/de/translation.json b/chatdesk-ui/public/locales/de/translation.json index 14cd265..763d46c 100644 --- a/chatdesk-ui/public/locales/de/translation.json +++ b/chatdesk-ui/public/locales/de/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Überprüfe deine E-Mails, um das Passwort zurückzusetzen.", "signupNotAllowed": "Die E-Mail-Adresse {{email}} ist nicht zur Registrierung zugelassen.", "unexpectedError": "Ein unerwarteter Fehler ist aufgetreten.", - "invalidCredentials": "Ungültige E-Mail-Adresse oder ungültiges Passwort." + "invalidCredentials": "Ungültige E-Mail-Adresse oder ungültiges Passwort.", + "clearing": "Anmeldestatus wird gelöscht..." }, "chat": { "defaultChatTitle": "Chat", diff --git a/chatdesk-ui/public/locales/en/translation.json b/chatdesk-ui/public/locales/en/translation.json index a6cb88e..f2b5b0f 100644 --- a/chatdesk-ui/public/locales/en/translation.json +++ b/chatdesk-ui/public/locales/en/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Check email to reset password", "signupNotAllowed": "Email {{email}} is not allowed to sign up.", "unexpectedError": "An unexpected error occurred", - "invalidCredentials": "Invalid email or password." + "invalidCredentials": "Invalid email or password.", + "clearing": "Clearing login state..." }, "chat": { "defaultChatTitle": "Chat", diff --git a/chatdesk-ui/public/locales/es/translation.json b/chatdesk-ui/public/locales/es/translation.json index 2f7864e..dca6e98 100644 --- a/chatdesk-ui/public/locales/es/translation.json +++ b/chatdesk-ui/public/locales/es/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Revisa tu correo para restablecer la contraseña.", "signupNotAllowed": "El correo {{email}} no está permitido para registrarse.", "unexpectedError": "Ocurrió un error inesperado.", - "invalidCredentials": "Correo electrónico o contraseña inválidos." + "invalidCredentials": "Correo electrónico o contraseña inválidos.", + "clearing": "Eliminando el estado de inicio de sesión..." }, "chat": { "defaultChatTitle": "Chat", diff --git a/chatdesk-ui/public/locales/fr/translation.json b/chatdesk-ui/public/locales/fr/translation.json index 3ec201d..5c12dc9 100644 --- a/chatdesk-ui/public/locales/fr/translation.json +++ b/chatdesk-ui/public/locales/fr/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Vérifiez votre e-mail pour réinitialiser le mot de passe", "signupNotAllowed": "L’e-mail {{email}} n’est pas autorisé à s’inscrire.", "unexpectedError": "Une erreur inattendue s’est produite", - "invalidCredentials": "E-mail ou mot de passe invalide." + "invalidCredentials": "E-mail ou mot de passe invalide.", + "clearing": "Suppression de l'état de connexion..." }, "chat": { "defaultChatTitle": "Discussion", diff --git a/chatdesk-ui/public/locales/he/translation.json b/chatdesk-ui/public/locales/he/translation.json index 445e3d4..753c8f5 100644 --- a/chatdesk-ui/public/locales/he/translation.json +++ b/chatdesk-ui/public/locales/he/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "בדוק את האימייל לאיפוס סיסמה", "signupNotAllowed": "האימייל {{email}} אינו מורשה להירשם.", "unexpectedError": "אירעה שגיאה בלתי צפויה", - "invalidCredentials": "אימייל או סיסמה לא נכונים." + "invalidCredentials": "אימייל או סיסמה לא נכונים.", + "clearing": "מנקה את מצב ההתחברות..." }, "chat": { "defaultChatTitle": "צ'אט", diff --git a/chatdesk-ui/public/locales/id/translation.json b/chatdesk-ui/public/locales/id/translation.json index e6b0dfd..71871f0 100644 --- a/chatdesk-ui/public/locales/id/translation.json +++ b/chatdesk-ui/public/locales/id/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Periksa email untuk mengatur ulang kata sandi", "signupNotAllowed": "Email {{email}} tidak diizinkan untuk mendaftar.", "unexpectedError": "Terjadi kesalahan yang tidak terduga", - "invalidCredentials": "Email atau kata sandi salah." + "invalidCredentials": "Email atau kata sandi salah.", + "clearing": "Menghapus status login..." }, "chat": { "defaultChatTitle": "Obrolan", diff --git a/chatdesk-ui/public/locales/it/translation.json b/chatdesk-ui/public/locales/it/translation.json index 83b3d32..3c9af21 100644 --- a/chatdesk-ui/public/locales/it/translation.json +++ b/chatdesk-ui/public/locales/it/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Controlla la tua email per reimpostare la password", "signupNotAllowed": "L'indirizzo email {{email}} non è autorizzato a registrarsi.", "unexpectedError": "Si è verificato un errore imprevisto", - "invalidCredentials": "Email o password non validi." + "invalidCredentials": "Email o password non validi.", + "clearing": "Pulizia dello stato di accesso..." }, "chat": { "defaultChatTitle": "Chat", diff --git a/chatdesk-ui/public/locales/ja/translation.json b/chatdesk-ui/public/locales/ja/translation.json index e559003..fdf3146 100644 --- a/chatdesk-ui/public/locales/ja/translation.json +++ b/chatdesk-ui/public/locales/ja/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "パスワードをリセットするにはメールを確認してください", "signupNotAllowed": "メールアドレス {{email}} は登録できません。", "unexpectedError": "予期しないエラーが発生しました", - "invalidCredentials": "メールアドレスまたはパスワードが正しくありません。" + "invalidCredentials": "メールアドレスまたはパスワードが正しくありません。", + "clearing": "ログイン状態をクリアしています..." }, "chat": { "defaultChatTitle": "会話", diff --git a/chatdesk-ui/public/locales/ko/translation.json b/chatdesk-ui/public/locales/ko/translation.json index d1f7f2c..941a185 100644 --- a/chatdesk-ui/public/locales/ko/translation.json +++ b/chatdesk-ui/public/locales/ko/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "비밀번호 재설정을 위해 이메일을 확인하세요.", "signupNotAllowed": "이메일 {{email}}은(는) 가입할 수 없습니다.", "unexpectedError": "예상치 못한 오류가 발생했습니다.", - "invalidCredentials": "이메일 또는 비밀번호가 올바르지 않습니다." + "invalidCredentials": "이메일 또는 비밀번호가 올바르지 않습니다.", + "clearing": "로그인 상태를 정리하는 중..." }, "chat": { "defaultChatTitle": "채팅", diff --git a/chatdesk-ui/public/locales/pt/translation.json b/chatdesk-ui/public/locales/pt/translation.json index ff7cc2d..f7b6262 100644 --- a/chatdesk-ui/public/locales/pt/translation.json +++ b/chatdesk-ui/public/locales/pt/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Verifique seu email para redefinir a senha", "signupNotAllowed": "O email {{email}} não está autorizado a se registrar.", "unexpectedError": "Ocorreu um erro inesperado", - "invalidCredentials": "Email ou senha inválidos." + "invalidCredentials": "Email ou senha inválidos.", + "clearing": "Limpando o estado de login..." }, "chat": { "defaultChatTitle": "Chat", diff --git a/chatdesk-ui/public/locales/ru/translation.json b/chatdesk-ui/public/locales/ru/translation.json index 478fc1e..2104288 100644 --- a/chatdesk-ui/public/locales/ru/translation.json +++ b/chatdesk-ui/public/locales/ru/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Проверьте почту для сброса пароля", "signupNotAllowed": "Электронная почта {{email}} не разрешена для регистрации.", "unexpectedError": "Произошла непредвиденная ошибка", - "invalidCredentials": "Неверный адрес эл. почты или пароль." + "invalidCredentials": "Неверный адрес эл. почты или пароль.", + "clearing": "Очистка состояния входа..." }, "chat": { "defaultChatTitle": "Чат", diff --git a/chatdesk-ui/public/locales/si/translation.json b/chatdesk-ui/public/locales/si/translation.json index 69bcd21..91aadd3 100644 --- a/chatdesk-ui/public/locales/si/translation.json +++ b/chatdesk-ui/public/locales/si/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "මුරපදය යළි පිහිටුවීමට ඊමේල් පරීක්ෂා කරන්න", "signupNotAllowed": "{{email}} යන්න ලියාපදිංචි වීමට අවසර නැත.", "unexpectedError": "予期 නොකළ දෝෂයක් ඇතිවිය", - "invalidCredentials": "අවලංගු ඊමේල් හෝ මුරපදයක්." + "invalidCredentials": "අවලංගු ඊමේල් හෝ මුරපදයක්.", + "clearing": "ඇතුල් වීමේ තත්වය මකාදමමින්..." }, "chat": { "defaultChatTitle": "කතාබස්", diff --git a/chatdesk-ui/public/locales/sv/translation.json b/chatdesk-ui/public/locales/sv/translation.json index 48db836..499151b 100644 --- a/chatdesk-ui/public/locales/sv/translation.json +++ b/chatdesk-ui/public/locales/sv/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Kontrollera din e-post för att återställa lösenordet", "signupNotAllowed": "E-postadressen {{email}} är inte tillåten för registrering.", "unexpectedError": "Ett oväntat fel inträffade", - "invalidCredentials": "Ogiltig e-postadress eller lösenord." + "invalidCredentials": "Ogiltig e-postadress eller lösenord.", + "clearing": "Rensar inloggningsstatus..." }, "chat": { "defaultChatTitle": "Chatt", diff --git a/chatdesk-ui/public/locales/te/translation.json b/chatdesk-ui/public/locales/te/translation.json index a191a28..8790ab0 100644 --- a/chatdesk-ui/public/locales/te/translation.json +++ b/chatdesk-ui/public/locales/te/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "పాస్వర్డ్ రీసెట్ చేయడానికి ఈమెయిల్ తనిఖీ చేయండి", "signupNotAllowed": "{{email}} చిరునామా నమోదు చేసుకోడానికి అనుమతించబడలేదు.", "unexpectedError": "అనుకోని లోపం సంభవించింది", - "invalidCredentials": "చెల్లని ఈమెయిల్ లేదా పాస్వర్డ్." + "invalidCredentials": "చెల్లని ఈమెయిల్ లేదా పాస్వర్డ్.", + "clearing": "లాగిన్ స్థితిని క్లియర్ చేస్తోంది..." }, "chat": { "defaultChatTitle": "చాట్", diff --git a/chatdesk-ui/public/locales/vi/translation.json b/chatdesk-ui/public/locales/vi/translation.json index 9cb81f7..193ddfa 100644 --- a/chatdesk-ui/public/locales/vi/translation.json +++ b/chatdesk-ui/public/locales/vi/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "Kiểm tra email để đặt lại mật khẩu", "signupNotAllowed": "Email {{email}} không được phép đăng ký.", "unexpectedError": "Đã xảy ra lỗi không mong muốn", - "invalidCredentials": "Email hoặc mật khẩu không hợp lệ." + "invalidCredentials": "Email hoặc mật khẩu không hợp lệ.", + "clearing": "Đang xóa trạng thái đăng nhập..." }, "chat": { "defaultChatTitle": "Trò chuyện", diff --git a/chatdesk-ui/public/locales/zh/translation.json b/chatdesk-ui/public/locales/zh/translation.json index 611bbf8..04e60d3 100644 --- a/chatdesk-ui/public/locales/zh/translation.json +++ b/chatdesk-ui/public/locales/zh/translation.json @@ -60,7 +60,8 @@ "checkEmailToReset": "请检查邮箱以重置密码", "signupNotAllowed": "邮箱 {{email}} 不允许注册。", "unexpectedError": "发生了未知错误", - "invalidCredentials": "邮箱或密码错误。" + "invalidCredentials": "邮箱或密码错误。", + "clearing": "正在清除登录状态..." }, "chat": { "defaultChatTitle": "对话",