How can I prevent authenticated users from accessing my Nuxt API if they are banned?
nuxt4
I'm currently using Nuxt 4.1.3 with Supabase 2.0.1. I've implemented authentication to check if a user is logged in, but I also need to verify if they are banned. My current setup checks if the user has data to determine their status.
However, I'm looking for a more robust method to prevent banned users from accessing my API endpoints.
Does anyone have suggestions or best practices to achieve this? Any guidance or code snippets would be greatly appreciated. Thank you!
import { serverSupabaseUser } from "#supabase/server"export async function authUser(event) { const user = await serverSupabaseUser(event) if (!user) { throw createError({ statusCode: 401, statusMessage: "Unauthorized - Please log in", }) } return user}
import { serverSupabaseUser } from "#supabase/server"export async function authUser(event) { const user = await serverSupabaseUser(event) if (!user) { throw createError({ statusCode: 401, statusMessage: "Unauthorized - Please log in", }) } return user}
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community