remove separate storage reference for account check

This commit is contained in:
2023-03-18 17:42:27 -06:00
parent cfeabf05a4
commit 5f3861049e
5 changed files with 74 additions and 56 deletions

View File

@@ -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" });