added next-intl, composed next-auth and next-intl in middleware, fixed some bugs, completed details page, added google auth

This commit is contained in:
Alibek committed 2024-02-29 14:09:37 +06:00
1 parent 9cd7b2a67d
commit 6637ab4eae
172 files changed
+1772 -502

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
"use client";
import { apiInstance } from "@/shared/config/apiConfig";
import { AxiosError } from "axios";
import { signOut, useSession } from "next-auth/react";
import { useEffect } from "react";
const AuthGuard = ({ children }: { children: React.ReactNode }) => {
const session = useSession();
const verifyToken = async () => {
try {
const data = {
token: session.data?.access_token,
};
await apiInstance.post("/token/verify/", data);
} catch (error: unknown) {
signOut({
callbackUrl: "/",
});
}
};
useEffect(() => {
if (session.status === "loading") return;
verifyToken();
}, [session.status]);
return <>{children}</>;
};
export default AuthGuard;