mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-29 03:33:17 +01:00
17 lines
512 B
JavaScript
Vendored
17 lines
512 B
JavaScript
Vendored
/**
|
|
* Allows an authenticated user to access the main view only if he owns at least one twofaccount.
|
|
* Push to the starter view otherwise.
|
|
*/
|
|
export default async function starter({ to, next, nextMiddleware, stores }) {
|
|
const { twofaccounts } = stores
|
|
|
|
if (twofaccounts.isEmpty) {
|
|
await twofaccounts.fetch().then(() => {
|
|
if (twofaccounts.isEmpty) {
|
|
next({ name: 'start' })
|
|
}
|
|
else nextMiddleware()
|
|
})
|
|
}
|
|
else nextMiddleware()
|
|
} |