You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
380 B
TypeScript

import { useApi } from "@/Api";
import type {
NavigationGuardNext,
RouteLocationNormalized,
Router,
} from "vue-router";
type Context = {
from: RouteLocationNormalized;
to: RouteLocationNormalized;
next: NavigationGuardNext;
router: Router;
};
export const auth = ({ next }: Context) => {
if (!useApi()?.isAuthorized()) next({ name: "auth" });
else next();
};