feat(auth,explore): Add NSFW content gating and age verification
- Add automatic NSFW settings for users registering on NSFW nodes - Implement age verification checkbox on registration form for NSFW nodes - Add NSFW node detection on explore page with gated content access - Restrict unauthenticated users from viewing posts on NSFW nodes - Fetch and display node NSFW status in explore and login pages - Update node info type to include isNsfw flag across auth flows - Display age-gated content warning with EyeOff icon for restricted access - Enforce age verification requirement before registration on adult nodes
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { registerUser, createSession } from '@/lib/auth';
|
||||
import { db, nodes, users } from '@/db';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { z } from 'zod';
|
||||
|
||||
const registerSchema = z.object({
|
||||
@@ -21,6 +23,22 @@ export async function POST(request: Request) {
|
||||
data.displayName
|
||||
);
|
||||
|
||||
// Check if this is an NSFW node and auto-enable NSFW settings
|
||||
const nodeDomain = process.env.NEXT_PUBLIC_NODE_DOMAIN || 'localhost:3000';
|
||||
const node = await db.query.nodes.findFirst({
|
||||
where: eq(nodes.domain, nodeDomain),
|
||||
});
|
||||
|
||||
if (node?.isNsfw) {
|
||||
// Auto-enable NSFW viewing and mark account as NSFW for users on NSFW nodes
|
||||
await db.update(users)
|
||||
.set({
|
||||
nsfwEnabled: true,
|
||||
isNsfw: true
|
||||
})
|
||||
.where(eq(users.id, user.id));
|
||||
}
|
||||
|
||||
// Create session for new user
|
||||
await createSession(user.id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user