🛂 (radar) Correctly block banned IP event when signing in with oauth providers
This commit is contained in:
@ -17,9 +17,10 @@ export const SignInError = ({ error }: Props) => {
|
|||||||
OAuthAccountNotLinked: t('auth.error.oauthNotLinked'),
|
OAuthAccountNotLinked: t('auth.error.oauthNotLinked'),
|
||||||
default: t('auth.error.unknown'),
|
default: t('auth.error.unknown'),
|
||||||
}
|
}
|
||||||
|
if (!errors[error]) return null
|
||||||
return (
|
return (
|
||||||
<Alert status="error" variant="solid" rounded="md">
|
<Alert status="error" variant="solid" rounded="md">
|
||||||
{errors[error] ?? errors[error]}
|
{errors[error]}
|
||||||
</Alert>
|
</Alert>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,17 @@ export const SignInForm = ({
|
|||||||
})()
|
})()
|
||||||
}, [status, router])
|
}, [status, router])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!router.isReady) return
|
||||||
|
if (router.query.error === 'ip-banned') {
|
||||||
|
showToast({
|
||||||
|
status: 'info',
|
||||||
|
description:
|
||||||
|
'Your account has suspicious activity and is being reviewed by our team. Feel free to contact us.',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [router.isReady, router.query.error, showToast])
|
||||||
|
|
||||||
const handleEmailChange = (e: ChangeEvent<HTMLInputElement>) =>
|
const handleEmailChange = (e: ChangeEvent<HTMLInputElement>) =>
|
||||||
setEmailValue(e.target.value)
|
setEmailValue(e.target.value)
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ export const getAuthOptions = ({
|
|||||||
pages: {
|
pages: {
|
||||||
signIn: '/signin',
|
signIn: '/signin',
|
||||||
newUser: env.NEXT_PUBLIC_ONBOARDING_TYPEBOT_ID ? '/onboarding' : undefined,
|
newUser: env.NEXT_PUBLIC_ONBOARDING_TYPEBOT_ID ? '/onboarding' : undefined,
|
||||||
|
error: '/signin',
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
signIn({ user }) {
|
signIn({ user }) {
|
||||||
@ -199,12 +200,12 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
env.RADAR_HIGH_RISK_KEYWORDS &&
|
env.RADAR_HIGH_RISK_KEYWORDS &&
|
||||||
req.url?.startsWith('/api/auth/signin') &&
|
((req.method === 'POST' && req.url?.startsWith('/api/auth/signin')) ||
|
||||||
req.method === 'POST'
|
(req.method === 'GET' && req.url?.startsWith('/api/auth/callback')))
|
||||||
) {
|
) {
|
||||||
const ip = getIp(req)
|
const ip = getIp(req)
|
||||||
if (ip) {
|
if (ip) {
|
||||||
const isIpBanned = await prisma.bannedIp.findFirst({
|
const isIpBanned = await prisma.bannedIp.count({
|
||||||
where: {
|
where: {
|
||||||
ip,
|
ip,
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user