mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-14 11:04:10 +00:00
fix: redirect if not logged in
This commit is contained in:
parent
6be186f950
commit
672a0fec00
6 changed files with 20 additions and 21 deletions
|
|
@ -7,6 +7,7 @@ import { getSpaces } from "@/app/actions/fetchers";
|
|||
import { useRouter } from "next/navigation";
|
||||
import { createChatThread, linkTelegramToUser } from "@/app/actions/doers";
|
||||
import { toast } from "sonner";
|
||||
import { useSession } from "next-auth/react";
|
||||
|
||||
function Page({
|
||||
searchParams,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import { LIMITS } from "@/lib/constants";
|
|||
import { z } from "zod";
|
||||
import { ChatHistory } from "@repo/shared-types";
|
||||
import { decipher } from "@/server/encrypt";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export const createSpace = async (
|
||||
input: string | FormData,
|
||||
|
|
@ -26,6 +27,7 @@ export const createSpace = async (
|
|||
const data = await auth();
|
||||
|
||||
if (!data || !data.user) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
@ -112,6 +114,7 @@ export const createMemory = async (input: {
|
|||
const data = await auth();
|
||||
|
||||
if (!data || !data.user || !data.user.id) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
@ -282,6 +285,7 @@ export const createChatThread = async (
|
|||
const data = await auth();
|
||||
|
||||
if (!data || !data.user || !data.user.id) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
@ -313,6 +317,7 @@ export const createChatObject = async (
|
|||
const data = await auth();
|
||||
|
||||
if (!data || !data.user || !data.user.id) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
@ -353,6 +358,7 @@ export const linkTelegramToUser = async (
|
|||
const data = await auth();
|
||||
|
||||
if (!data || !data.user || !data.user.id) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,13 @@ import { ServerActionReturnType, Space } from "./types";
|
|||
import { auth } from "../../server/auth";
|
||||
import { ChatHistory, SourceZod } from "@repo/shared-types";
|
||||
import { z } from "zod";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export const getSpaces = async (): ServerActionReturnType<Space[]> => {
|
||||
const data = await auth();
|
||||
|
||||
if (!data || !data.user) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +41,7 @@ export const getAllMemories = async (
|
|||
const data = await auth();
|
||||
|
||||
if (!data || !data.user) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +81,7 @@ export const getAllUserMemoriesAndSpaces = async (): ServerActionReturnType<{
|
|||
const data = await auth();
|
||||
|
||||
if (!data || !data.user) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +105,7 @@ export const getFullChatThread = async (
|
|||
const data = await auth();
|
||||
|
||||
if (!data || !data.user || !data.user.id) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
"packageManager": "yarn@1.22.21",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "bun pages:build",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "eslint . --max-warnings 0",
|
||||
"cf-typegen": "wrangler types --env-interface CloudflareEnv env.d.ts",
|
||||
"pages:build": "npx @cloudflare/next-on-pages",
|
||||
"preview": "bun pages:build && wrangler pages dev",
|
||||
"deploy": "bun pages:build && wrangler pages deploy",
|
||||
"preview": "npm run pages:build && wrangler pages dev",
|
||||
"deploy": "npm run pages:build && wrangler pages deploy",
|
||||
"schema-update": "bunx drizzle-kit generate sqlite",
|
||||
"update-local-db": "bunx wrangler d1 execute dev-d1-anycontext --local"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,24 +11,11 @@ mode = "smart"
|
|||
binding = "STORAGE"
|
||||
bucket_name = "dev-r2-anycontext"
|
||||
|
||||
# [env.preview]
|
||||
# [[env.preview.d1_databases]]
|
||||
# binding = "DATABASE"
|
||||
# database_name = "dev-d1-anycontext"
|
||||
# database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c"
|
||||
|
||||
# [env.production]
|
||||
# [[env.production.d1_databases]]
|
||||
|
||||
[[d1_databases]]
|
||||
binding = "DATABASE"
|
||||
database_name = "prod-d1-supermemory"
|
||||
database_id = "f527a727-c472-41d4-8eaf-3d7ba0f2f395"
|
||||
# database_name = "prod-d1-supermemory"
|
||||
# database_id = "f527a727-c472-41d4-8eaf-3d7ba0f2f395"
|
||||
|
||||
# [[unsafe.bindings]]
|
||||
# name = "RATELIMITER"
|
||||
# type = "ratelimit"
|
||||
# namespace_id = "1001"
|
||||
|
||||
# # 25 requests per 10 seconds
|
||||
# simple = { limit = 25, period = 10 }
|
||||
database_name = "dev-d1-anycontext"
|
||||
database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c"
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"packageManager": "bun@1.1.8",
|
||||
"packageManager": "yarn@1.22.21",
|
||||
"workspaces": [
|
||||
"apps/*",
|
||||
"packages/*"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue