This commit is contained in:
parent
b6f22fda2c
commit
27961c2143
|
|
@ -52,13 +52,29 @@ export default async function Login({
|
|||
.select("*")
|
||||
.eq("user_id", session.user.id)
|
||||
.eq("is_home", true)
|
||||
.single()
|
||||
.limit(1); // Limit to 1 row
|
||||
//.single()
|
||||
|
||||
if (!homeWorkspace) {
|
||||
throw new Error(error.message)
|
||||
// if (!homeWorkspace) {
|
||||
// throw new Error(error.message)
|
||||
// }
|
||||
|
||||
|
||||
if (!homeWorkspace || homeWorkspace.length === 0) {
|
||||
// Handle the case where no rows are found
|
||||
throw new Error("No home workspace found for this user.");
|
||||
}
|
||||
|
||||
// console.log("[login page]======>Redirecting to workspace:", homeWorkspace.id)
|
||||
// If more than 1 row is returned, we handle that case
|
||||
if (homeWorkspace.length > 1) {
|
||||
// Handle the case where multiple rows are returned
|
||||
console.warn("Multiple home workspaces found for this user.");
|
||||
}
|
||||
|
||||
// Since we used `.limit(1)`, we can safely use `.single()` now
|
||||
const workspace = homeWorkspace[0]; // Use the first (and only) row
|
||||
|
||||
|
||||
return redirect(`/${localeString}/${homeWorkspace.id}/chat`)
|
||||
|
||||
}
|
||||
|
|
@ -87,7 +103,22 @@ export default async function Login({
|
|||
.select("*")
|
||||
.eq("user_id", data.user.id)
|
||||
.eq("is_home", true)
|
||||
.single()
|
||||
.limit(1); // Limit to 1 row
|
||||
//.single()
|
||||
|
||||
if (!homeWorkspace || homeWorkspace.length === 0) {
|
||||
// Handle the case where no rows are found
|
||||
throw new Error(homeWorkspaceError?.message || "No home workspace found for this user.");
|
||||
}
|
||||
|
||||
// If more than 1 row is returned, we handle that case
|
||||
if (homeWorkspace.length > 1) {
|
||||
// Handle the case where multiple rows are returned
|
||||
console.warn("Multiple home workspaces found for this user.");
|
||||
}
|
||||
|
||||
// Since we used `.limit(1)`, we can safely use `.single()` now
|
||||
const workspace = homeWorkspace[0]; // Use the first (and only) row
|
||||
|
||||
if (!homeWorkspace) {
|
||||
//const fallbackMessage = String(t("login.unexpectedError"))
|
||||
|
|
|
|||
Loading…
Reference in New Issue