remove separate storage reference for account check
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
|
||||
import { useAppStore } from "../store/app";
|
||||
import { db } from "@/db";
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
@@ -7,10 +7,10 @@ const routes: Array<RouteRecordRaw> = [
|
||||
name: "home",
|
||||
component: () =>
|
||||
import(/* webpackChunkName: "start" */ "../views/DiscoverView.vue"),
|
||||
beforeEnter: (to, from, next) => {
|
||||
const appStore = useAppStore();
|
||||
const isAuthenticated = appStore.condition === "registered";
|
||||
if (isAuthenticated) {
|
||||
beforeEnter: async (to, from, next) => {
|
||||
await db.open();
|
||||
const num_accounts = await db.accounts.count();
|
||||
if (num_accounts > 0) {
|
||||
next();
|
||||
} else {
|
||||
next({ name: "start" });
|
||||
|
||||
Reference in New Issue
Block a user