stefanvanherwijnen / quasar-app-extension-http-authentication

Token based authentication for Quasar Framework
MIT License
68 stars 15 forks source link

redirect to login when not authed #19

Closed diegopamio closed 2 years ago

diegopamio commented 4 years ago

So far it looks like if the auth doesn't work, it redirects to /, is there a way to do that with this extension?

  router.beforeEach((to, from, next) => {
    const record = to.matched.find(record => record.meta.auth)
    if (record) {
      if (!store.getters['auth/loggedIn']) {
        return store.dispatch('auth/fetch').then((data) => {
          if (!store.getters['auth/loggedIn']) {
            next('/')
          } else if (
            isArrayOrString(record.meta.auth) &&
            !store.getters['auth/check'](record.meta.auth)
          ) {
            next('/account')
          } else {
            next()
          }
        }).catch(err => {
       --->   next('/')
        })
      } else if (
        isArrayOrString(record.meta.auth) &&
        !store.getters['auth/check'](record.meta.auth)
      ) {
        return next('/account')
      }
    }
    next()
  })
stefanvanherwijnen commented 4 years ago

Not at the moment. I'll try to incorporate it in the next update.

I think the ideal way is redirecting back to the previous page after you have been redirect to login, but there will have to be a check if it was a redirect or manual route.

stefanvanherwijnen commented 2 years ago

Should be fixed or no longer applicable in v2.