From 84b45cd6b11347e66437cd92dc20372d0abd6eb9 Mon Sep 17 00:00:00 2001 From: Joseph Ditton Date: Wed, 1 Dec 2021 20:18:26 -0700 Subject: adds roles --- client/utils/parse_jwt.js | 5 +++++ client/utils/roles_context.js | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 client/utils/parse_jwt.js create mode 100644 client/utils/roles_context.js (limited to 'client/utils') diff --git a/client/utils/parse_jwt.js b/client/utils/parse_jwt.js new file mode 100644 index 0000000..38b4bf9 --- /dev/null +++ b/client/utils/parse_jwt.js @@ -0,0 +1,5 @@ +export const parseJwt = (token) => { + if (!token) return {}; + const jwtPayload = JSON.parse(window.atob(token.split('.')[1])); + return jwtPayload; +}; diff --git a/client/utils/roles_context.js b/client/utils/roles_context.js new file mode 100644 index 0000000..089de6a --- /dev/null +++ b/client/utils/roles_context.js @@ -0,0 +1,3 @@ +import { createContext } from 'react'; + +export const RolesContext = createContext({}); -- cgit v1.2.3-70-g09d2