mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 01:02:04 +00:00
Check session for decrypt, check session and admin for encrypt
This commit is contained in:
parent
7953bb641f
commit
107f6b4499
@ -1,10 +1,18 @@
|
||||
import { nip04 } from 'nostr-tools';
|
||||
import { getServerSession } from "next-auth/next"
|
||||
import { authOptions } from "@/pages/api/auth/[...nextauth]"
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const session = await getServerSession(req, res, authOptions)
|
||||
|
||||
if (req.method !== 'POST') {
|
||||
return res.status(405).json({ error: 'Method Not Allowed' });
|
||||
}
|
||||
|
||||
if (!session) {
|
||||
return res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
const { encryptedContent } = req.body;
|
||||
|
||||
if (!encryptedContent) {
|
||||
|
@ -1,10 +1,18 @@
|
||||
import { nip04 } from 'nostr-tools';
|
||||
import { getServerSession } from "next-auth/next"
|
||||
import { authOptions } from "@/pages/api/auth/[...nextauth]"
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const session = await getServerSession(req, res, authOptions)
|
||||
|
||||
if (req.method !== 'POST') {
|
||||
return res.status(405).json({ error: 'Method Not Allowed' });
|
||||
}
|
||||
|
||||
if (!session || !session.user.role?.admin) {
|
||||
return res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
const { content } = req.body;
|
||||
|
||||
if (!content) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user