No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Route guard with stored location

    Help
    2
    2
    145
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nobilik last edited by

      Hi!

      I’m trying to implement route guard that will store desired location for user that not yet logged in and redirect to it after login.

      let storedURL = null
        router.beforeEach((to, from, next) => {
          const record = to.matched.find(record => record.meta.auth)
          if (record) {
            if (store.getters['auth/check']) {
              if (storedURL) {
                const redirectURL = storedURL
                storedURL = null
                next(redirectURL)
              } else {
                next()
              }
            } else {
              storedURL = to.path
              next('/')
            }
          } else {
            if (to.path === '/' && store.getters['auth/check']) {
              next('/dashboard')
            } else {
              next()
            }
          }
        })
      

      It works, but on store location I have warning in my console:

      Error: Script terminated by timeout at:
      notify@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:730:36
      reactiveSetter@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:1056:11
      proxySetter@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:4625:5
      __onControlFocusin@webpack-internal:///./node_modules/quasar/src/components/field/QField.js:345:9
      invokeWithErrorHandling@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:1853:26
      invoker@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:2178:14
      add$1/original._wrapper@webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:6907:25
      

      And on redirect I have an error:

      uncaught exception: undefined
      

      Can’t understand what is wrong

      1 Reply Last reply Reply Quote 0
      • T
        twa last edited by

        Did you solve?

        1 Reply Last reply Reply Quote 0
        • First post
          Last post