Skip to content

Commit

Permalink
format whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourgreens committed Oct 2, 2024
1 parent 706a855 commit 817b482
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/lib-user/src/hooks/usePanoptesAuthToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import auth from "panoptes-client/lib/auth";
import { useState } from "react";

const isBrowser = typeof window !== "undefined";

if (isBrowser) {
auth.checkCurrent();
}

export default function usePanoptesAuthToken() {
const [token, setToken] = useState(null);

async function fetchPanoptesAuthToken() {
await auth.checkCurrent();
const newToken = await auth.checkBearerToken();
if (newToken !== token) {
setToken(newToken);
}
}

fetchPanoptesAuthToken();
return token;
}

0 comments on commit 817b482

Please sign in to comment.