I have the following pages/routes in my setup:
login/index.vue - to log the user in
dashboard/index.vue - which can only be seen by logged-in users
register/onboarding.vue - which should be redirected to, if the registration process is incomplete
I have configured middleware/auth.js as follows to force the user to complete the registration process if registrationComplete is false:
export default function ({ redirect, $strapi }) {
// default condition (example from https://strapi.nuxtjs.org/usage)
if (!$strapi.user) {
return redirect('/login')
}
// DEBUG
console.log('$strapi.user.registrationComplete', $strapi.user.registrationComplete)
// custom condition
if (!$strapi.user.registrationComplete) {
return redirect('/register/onboarding')
}
}
Then I use middleware: 'auth' on the dashboard/index.vue and register/onboarding.vue page.
What is Expected?
I expect to be redirected to the onboarding page if the users flag registrationComplete is false
What is actually happening?
I get an error from the browser: A webpage is slowing down your browser what would you like to do? Stop/Wait
Inside the browser console I can see from the debug line above that console.log('$strapi.user.registrationComplete', $strapi.user.registrationComplete) gets into an endless loop and is executed thousands of times!
If I remove my custom condition inside auth.js, it gets out of the endless loop. What is happening here?
Version
@nuxtjs/strapi: v0.1.6 nuxt: v2.14.0
Reproduction Link
I don't have one yet
Steps to reproduce
I have the following pages/routes in my setup:
login/index.vue
- to log the user indashboard/index.vue
- which can only be seen by logged-in usersregister/onboarding.vue
- which should be redirected to, if the registration process is incompleteI have configured
middleware/auth.js
as follows to force the user to complete the registration process ifregistrationComplete
isfalse
:Then I use
middleware: 'auth'
on thedashboard/index.vue
andregister/onboarding.vue
page.What is Expected?
I expect to be redirected to the onboarding page if the users flag
registrationComplete
isfalse
What is actually happening?
I get an error from the browser:
A webpage is slowing down your browser what would you like to do? Stop/Wait
Inside the browser console I can see from the debug line above thatconsole.log('$strapi.user.registrationComplete', $strapi.user.registrationComplete)
gets into an endless loop and is executed thousands of times! If I remove my custom condition insideauth.js
, it gets out of the endless loop. What is happening here?