V
V
Vladislav2022-02-20 14:38:45
Vue.js
Vladislav, 2022-02-20 14:38:45

VueJs, page hangs when two redirects conflict, how to fix?

export default function({$auth, redirect}) {
  // Если не подтверждена почта
  if ($auth.loggedIn && !$auth.user.email_verified_at) {
    return redirect('/auth/verify-email')
  }
}

After entering, there is a redirect to the main one, as well as this check for confirmation of mail with redirection if not confirmed. It turns out a redirect to a redirect and the page hangs, how to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav, 2022-02-21
@Vladddosss

Decided so.

export default function({$auth, route, redirect}) {
  // Если не подтверждена почта
  if ($auth.loggedIn && !$auth.user.email_verified_at) {
    // Не вызывать переадресацию на /auth/verify-email
    if (route.path !== '/auth/verify-email') {
      return redirect('/auth/verify-email')
    }
  }
}

A
Aetae, 2022-02-20
@Aetae

Classic. The solution is obvious: don't call this function if you don't need to. or something like that. if(to.path === '/auth/verify-email') next()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question