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/app.jsx | |
parent | d803aaaf1be441f55fe674c3b0c6793e77a9203f (diff) | |
download | locchat-84b45cd6b11347e66437cd92dc20372d0abd6eb9.tar.gz locchat-84b45cd6b11347e66437cd92dc20372d0abd6eb9.zip |
adds roles
Diffstat (limited to 'client/app.jsx')
-rw-r--r-- | client/app.jsx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/client/app.jsx b/client/app.jsx index e1e4c03..90ceb37 100644 --- a/client/app.jsx +++ b/client/app.jsx @@ -6,6 +6,8 @@ import { AuthContext } from './utils/auth_context'; import { useApi } from './utils/use_api'; import { useJwtRefresh } from './utils/use_jwt_refresh'; import './app.css'; +import { RolesContext } from './utils/roles_context'; +import { parseJwt } from './utils/parse_jwt'; export const App = () => { const [authToken, setAuthToken] = useState(null); @@ -26,16 +28,21 @@ export const App = () => { setLoading(false); }, []); - // before displaying anything try getting a token using cookies, + const jwtPayload = parseJwt(authToken); + console.log(jwtPayload); + + // don't display anything while trying to get user token // can display a loading screen here if desired if (loading) return null; return ( <AuthContext.Provider value={[authToken, setAuthToken]}> <ApiContext.Provider value={api}> - <HashRouter> - <Router /> - </HashRouter> + <RolesContext.Provider value={jwtPayload.roles}> + <HashRouter> + <Router /> + </HashRouter> + </RolesContext.Provider> </ApiContext.Provider> </AuthContext.Provider> ); |