mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-24 14:02:09 +02:00
Add the twofaccounts store to stores passed to the router middlewares
This commit is contained in:
parent
79827663fe
commit
40ea767799
4
resources/js_vue3/router/index.js
vendored
4
resources/js_vue3/router/index.js
vendored
@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import middlewarePipeline from "@/router/middlewarePipeline";
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useTwofaccounts } from '@/stores/twofaccounts'
|
||||
|
||||
import Start from '../views/Start.vue'
|
||||
import Accounts from '../views/Accounts.vue'
|
||||
@ -74,7 +75,8 @@ const router = createRouter({
|
||||
router.beforeEach((to, from, next) => {
|
||||
const middlewares = to.meta.middlewares
|
||||
const user = useUserStore()
|
||||
const stores = { user: user }
|
||||
const twofaccounts = useTwofaccounts()
|
||||
const stores = { user: user, twofaccounts: twofaccounts }
|
||||
const context = { to, from, next, stores }
|
||||
|
||||
if (!middlewares) {
|
||||
|
@ -1,11 +1,9 @@
|
||||
import { useTwofaccounts } from '@/stores/twofaccounts'
|
||||
|
||||
/**
|
||||
* Allows the user to access the main view only if he owns at least one twofaccount.
|
||||
* 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 function starter({ to, next }) {
|
||||
const twofaccounts = useTwofaccounts()
|
||||
export default function starter({ to, next, stores }) {
|
||||
const { twofaccounts } = stores
|
||||
|
||||
if (twofaccounts.isEmpty) {
|
||||
twofaccounts.refresh().then(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user