import type { RouteLocationRaw } from "vue-router";
import { ensureValidAuthToken } from "@/utils/request";
import { goLogin } from "./useNavigator";

export const checkToken = async (redirect?: RouteLocationRaw) => {
  try {
    const token = await ensureValidAuthToken();
    if (!token) {
      goLogin({ redirect });
      return;
    }
  } catch {
    goLogin({ redirect });
  }
};
