export default defineEventHandler(async (event) => {
  const config = useRuntimeConfig()
  const body = await readBody(event)
  let user: any = {}

  if(event.context.auth.user) {
    user = event.context.auth.user
    user.isActive = true
  } else {
    await $fetch(config.api.url+'/activate?key='+body.key, {
      headers: {
        'Authorization': 'Bearer '+event.context.auth.token
      }
    })

    user.isActive = true
  }

  return user
})