nuxt-auth icon indicating copy to clipboard operation
nuxt-auth copied to clipboard

`definePageMeta({ auth: {} })` disables auth for the page

Open mackenzie-3spread opened this issue 2 years ago • 2 comments

Environment

  • Operating System: Darwin
  • Node Version: v20.16.0
  • Nuxt Version: 3.12.4
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • "@sidebase/nuxt-auth": "^0.8.2",

Reproduction

The following page when navigated to redirects the user to the default login page:

<script setup lang="ts">
definePageMeta({
  auth: true,
});
</script>
<template>yeet</template>

Changing the bool value of auth to an object and including navigateUnauthenticatedTo, user can now see the contents of the page and is not redirected:

<script setup lang="ts">
definePageMeta({
  auth: {
    navigateUnauthenticatedTo: "/auth/error",
  },
});
</script>
<template>yeet</template>

Describe the bug

When using the navigateUnauthenticatedTo method on a page, the user is able to view the contents of that page and is not redirected to the specified page, indicating that auth is disabled.

Additional context

No response

Logs

No response

mackenzie-3spread avatar Oct 12 '24 21:10 mackenzie-3spread

Thank you for the report, I've been able to reproduce it simply by using

definePageMeta({
  auth: {}
})

I will provide a fix shortly

phoenix-ru avatar Oct 17 '24 09:10 phoenix-ru

For the context @mackenzie-3spread - you are now required to provide unauthenticatedOnly option, otherwise it will default to Guest Mode (which you were incorrectly experiencing)

https://auth.sidebase.io/guide/application-side/protecting-pages#unauthenticatedonly

phoenix-ru avatar Oct 17 '24 16:10 phoenix-ru