🛂 Auto ban IP on suspected bot publishing (#1095)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced sign-in error handling with specific messages for different error types. - Implemented IP-based restrictions for authentication and publishing actions. - **Bug Fixes** - Updated the retrieval of user session information to improve reliability. - **Documentation** - Updated usage instructions for `getServerSession` to reflect the new authentication options. - **Refactor** - Replaced direct usage of `authOptions` with a new function `getAuthOptions` to dynamically generate authentication options. - Improved IP address extraction logic to handle various header formats. - **Chores** - Added a new `BannedIp` model to the database schema for managing IP-based restrictions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { authOptions } from '@/pages/api/auth/[...nextauth]'
|
||||
import { getAuthOptions } from '@/pages/api/auth/[...nextauth]'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { User } from '@typebot.io/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
@@ -15,7 +15,7 @@ export const getAuthenticatedUser = async (
|
||||
if (bearerToken) return authenticateByToken(bearerToken)
|
||||
const user = env.NEXT_PUBLIC_E2E_TEST
|
||||
? mockedUser
|
||||
: ((await getServerSession(req, res, authOptions))?.user as
|
||||
: ((await getServerSession(req, res, getAuthOptions({})))?.user as
|
||||
| User
|
||||
| undefined)
|
||||
if (!user || !('id' in user)) return
|
||||
|
||||
Reference in New Issue
Block a user