mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-24 05:51:48 +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 { createRouter, createWebHistory } from 'vue-router'
|
||||||
import middlewarePipeline from "@/router/middlewarePipeline";
|
import middlewarePipeline from "@/router/middlewarePipeline";
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { useTwofaccounts } from '@/stores/twofaccounts'
|
||||||
|
|
||||||
import Start from '../views/Start.vue'
|
import Start from '../views/Start.vue'
|
||||||
import Accounts from '../views/Accounts.vue'
|
import Accounts from '../views/Accounts.vue'
|
||||||
@ -74,7 +75,8 @@ const router = createRouter({
|
|||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
const middlewares = to.meta.middlewares
|
const middlewares = to.meta.middlewares
|
||||||
const user = useUserStore()
|
const user = useUserStore()
|
||||||
const stores = { user: user }
|
const twofaccounts = useTwofaccounts()
|
||||||
|
const stores = { user: user, twofaccounts: twofaccounts }
|
||||||
const context = { to, from, next, stores }
|
const context = { to, from, next, stores }
|
||||||
|
|
||||||
if (!middlewares) {
|
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.
|
* Push to the starter view otherwise.
|
||||||
*/
|
*/
|
||||||
export default function starter({ to, next }) {
|
export default function starter({ to, next, stores }) {
|
||||||
const twofaccounts = useTwofaccounts()
|
const { twofaccounts } = stores
|
||||||
|
|
||||||
if (twofaccounts.isEmpty) {
|
if (twofaccounts.isEmpty) {
|
||||||
twofaccounts.refresh().then(() => {
|
twofaccounts.refresh().then(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user