diff options
author | Joseph Ditton <jditton.atomic@gmail.com> | 2021-12-01 20:18:26 -0700 |
---|---|---|
committer | Joseph Ditton <jditton.atomic@gmail.com> | 2021-12-01 20:18:26 -0700 |
commit | 84b45cd6b11347e66437cd92dc20372d0abd6eb9 (patch) | |
tree | 6e42b5861278485c67159dc57c225983e3fd69f8 /client/utils | |
parent | d803aaaf1be441f55fe674c3b0c6793e77a9203f (diff) | |
download | locchat-84b45cd6b11347e66437cd92dc20372d0abd6eb9.tar.gz locchat-84b45cd6b11347e66437cd92dc20372d0abd6eb9.zip |
adds roles
Diffstat (limited to 'client/utils')
-rw-r--r-- | client/utils/parse_jwt.js | 5 | ||||
-rw-r--r-- | client/utils/roles_context.js | 3 |
2 files changed, 8 insertions, 0 deletions
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({}); |