map to new back

This commit is contained in:
kandrusyak
2023-07-25 02:11:01 +03:00
parent dcaa7b7995
commit 35ff1150e7
5 changed files with 120 additions and 12497 deletions

View File

@@ -6,19 +6,19 @@ import TheMedcards from "@/pages/medcards/TheMedcards";
import TheLogin from "@/pages/login/TheLogin";
import LoggedInLayout from "@/components/LoggedInLayout";
import TheMedicalCard from "@/pages/newMedicalCard/TheMedicalCard";
import { fetchWrapper } from "@/shared/fetchWrapper";
const ifNotAuthenticated = (to, from, next) => {
if (!localStorage.getItem("tokenAccess")) {
return next();
}
next("/");
const ifNotAuthenticated = async (to, from, next) => {
const data = await fetchWrapper.get("users/me");
if (!data) return next();
return next("/");
};
const ifAuthenticated = (to, from, next) => {
if (localStorage.getItem("tokenAccess")) {
return next();
}
next("/login");
const ifAuthenticated = async (to, from, next) => {
const data = await fetchWrapper.get("users/me");
if (!data) return next("/login");
return next();
};
export default createRouter({