How to allow anonymous access to a route using requiresAuth meta tag

Hi,
I have developed a Vue app with a .net Core backend following the following blog:
https://developer.okta.com/blog/2018/01/31/build-secure-todo-app-vuejs-aspnetcore

In my router I have setup a route guard using the $auth plugin as below:

let routes = [
  homePages,
  authPages,
  userPages,
  cardPages,
  projectPages,
  { path: '/implicit/callback', component: Auth.handleCallback() }
]

const router = new Router({
  mode: 'history',
  base: __dirname,
  routes
})

// Check the authentication status before router transitions
router.beforeEach(Vue.prototype.$auth.authRedirectGuard())

I was wondering if anyone can tell me how to allow a user anonymous access to a page (eg the registration page)? With the current config above all pages are tested to see of a user is not authenticated and its not possible for an anonymous user to access a page.

Ive tried putting a meta tag with ‘requiresAuth: false’ without success;

let authPages = {
  path: '/auth',
  name: 'Auth',
  component: PlainLayout,
  meta: {
    requiresAuth: false
  },
  children: [
    {
      path: 'register',
      name: 'Register',
      component: () => import('./views/auth/Register.vue'),
      meta: {
        requiresAuth: false
      }
    },
    {
      path: 'login',
      name: 'Login',
      component: () => import('./views/auth/Login.vue')
    },
    {
      path: 'forgotPassword',
      name: 'ForgotPassword',
      component: () => import('./views/auth/ForgotPassword.vue')
    },
    {
      path: 'resetPassword',
      name: 'resetPassword',
      component: () => import('./views/auth/ResetPassword.vue')
    }
  ]
}

Any help would be great. thank you kindly.
Adam

Just remove the meta/requiresAuth from the route and anyone will be able to access it.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.