Files

18 lines
538 B
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { db } from '@/server/fake-db/auth'
export default defineEventHandler(async event => {
const session = await setAuthOnlyRoute(event, 'You must be signed in to get your data.')
const dbUser = db.users.find(user => user.email === session.user?.email)
if (!dbUser) {
throw createError({
statusCode: 403,
statusMessage: `User with email "${session.user?.email}" not found in records.`,
})
}
// Don't send password in response
const { password: _, ...response } = dbUser
return response
})