mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-27 02:38:45 +02:00
Improve billing and access control by adding creator subscription check; update route components to enforce user authentication before viewing streams and replays.
This commit is contained in:
@@ -2,7 +2,7 @@ import { createFileRoute } from "@tanstack/react-router"
|
||||
import { and, desc, eq } from "drizzle-orm"
|
||||
import { db } from "@/db/connection"
|
||||
import { getAuth } from "@/lib/auth"
|
||||
import { hasActiveSubscription } from "@/lib/billing"
|
||||
import { hasCreatorSubscription } from "@/lib/billing"
|
||||
import { stream_replays, users } from "@/db/schema"
|
||||
|
||||
const json = (data: unknown, status = 200) =>
|
||||
@@ -56,7 +56,7 @@ const handleGet = async ({
|
||||
}
|
||||
}
|
||||
|
||||
// Non-owners need subscription to view replays
|
||||
// Non-owners need subscription to this creator to view replays
|
||||
if (!session?.user?.id) {
|
||||
return json(
|
||||
{ error: "Subscription required", code: "SUBSCRIPTION_REQUIRED" },
|
||||
@@ -64,7 +64,7 @@ const handleGet = async ({
|
||||
)
|
||||
}
|
||||
|
||||
const hasSubscription = await hasActiveSubscription(session.user.id)
|
||||
const hasSubscription = await hasCreatorSubscription(session.user.id, user.id)
|
||||
if (!hasSubscription) {
|
||||
return json(
|
||||
{ error: "Subscription required", code: "SUBSCRIPTION_REQUIRED" },
|
||||
|
||||
Reference in New Issue
Block a user