We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 57755c0 commit fc9db08Copy full SHA for fc9db08
frontend/src/contexts/UserContext.tsx
@@ -1,5 +1,6 @@
1
"use client";
2
3
+import { parseJwt } from "@/lib/auth";
4
import {
5
AccessToken,
6
AccessTokenPayload,
@@ -34,17 +35,3 @@ export function UserProvider({ children }: PropsWithChildren) {
34
35
export function useUser() {
36
return useContext(UserContext);
37
}
-
38
-function parseJwt(token: AccessToken): AccessTokenPayload {
39
- const base64Url = token.split(".")[1];
40
- const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
41
- const jsonPayload = decodeURIComponent(
42
- atob(base64)
43
- .split("")
44
- .map((c) => {
45
- return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
46
- })
47
- .join("")
48
- );
49
- return AccessTokenPayloadSchema.parse(JSON.parse(jsonPayload));
50
-}
0 commit comments