Initial commit: Cat Sitting Planner with PWA, SQLite, and Webhook Notifications
This commit is contained in:
25
app/actions/auth.ts
Normal file
25
app/actions/auth.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
"use server"
|
||||
|
||||
import { cookies } from "next/headers"
|
||||
import prisma from "@/lib/prisma"
|
||||
|
||||
export async function verifyPlanPassword(planId: string, password: string) {
|
||||
const plan = await prisma.plan.findUnique({
|
||||
where: { id: planId },
|
||||
})
|
||||
|
||||
if (!plan) return false
|
||||
|
||||
if (plan.password === password) {
|
||||
// Set a simple cookie to authorize this plan
|
||||
(await cookies()).set(`plan_auth_${planId}`, "true", {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
maxAge: 60 * 60 * 24 * 30, // 30 days
|
||||
path: "/",
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user