2023-10-25 17:26:32 +02:00
|
|
|
/**
|
2023-10-27 15:16:07 +02:00
|
|
|
* Allows an authenticated user to access the main view only if he owns at least one twofaccount.
|
2023-10-25 17:26:32 +02:00
|
|
|
* Push to the starter view otherwise.
|
|
|
|
*/
|
2023-11-15 17:27:29 +01:00
|
|
|
export default async function starter({ to, next, nextMiddleware, stores }) {
|
2023-10-27 15:16:07 +02:00
|
|
|
const { twofaccounts } = stores
|
2023-10-25 17:26:32 +02:00
|
|
|
|
|
|
|
if (twofaccounts.isEmpty) {
|
2023-11-15 17:27:29 +01:00
|
|
|
await twofaccounts.fetch().then(() => {
|
2023-10-25 17:26:32 +02:00
|
|
|
if (twofaccounts.isEmpty) {
|
2023-11-06 13:17:13 +01:00
|
|
|
next({ name: 'start' })
|
2023-10-25 17:26:32 +02:00
|
|
|
}
|
2023-11-15 14:07:26 +01:00
|
|
|
else nextMiddleware()
|
2023-10-25 17:26:32 +02:00
|
|
|
})
|
|
|
|
}
|
2023-11-15 14:07:26 +01:00
|
|
|
else nextMiddleware()
|
2023-10-25 17:26:32 +02:00
|
|
|
}
|