diff options
Diffstat (limited to 'src/clients')
-rw-r--r-- | src/clients/loaders.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/clients/loaders.ts b/src/clients/loaders.ts index a114e8d..f3d01cc 100644 --- a/src/clients/loaders.ts +++ b/src/clients/loaders.ts @@ -2,10 +2,19 @@ import { redirect } from "react-router-dom"; import { ApiClient } from "./api_client"; import { Product, mapProduct } from "../models/product"; import { Card } from "../models/card"; +import { refreshIfExpired, logout, presentSession } from "../lib/session"; import Token from "../lib/token"; import Order from "../models/order"; export async function loader({ request }) { + if(presentSession()) { + if(!refreshIfExpired()) { + logout(); + + return redirect('/products'); + } + } + const client = new ApiClient(); const url = new URL(request.url) const response = await client.get(`${url.pathname}${url.search}`); |