Bachelorthesis_Code/frontend/src/auth/AuthProvider.js
2021-06-23 03:40:37 +02:00

10 lines
306 B
JavaScript

import { createAuthProvider } from "react-token-auth";
export const [useAuth, authFetch, login, logout] = createAuthProvider({
accessTokenKey: "access_token",
onUpdateToken: (token) =>
fetch("/api/refresh", {
method: "POST",
body: token.access_token,
}).then((r) => r.json()),
});