summaryrefslogtreecommitdiff
path: root/client/app.jsx
diff options
context:
space:
mode:
authorJoseph Ditton <jditton.atomic@gmail.com>2021-12-01 20:18:26 -0700
committerJoseph Ditton <jditton.atomic@gmail.com>2021-12-01 20:18:26 -0700
commit84b45cd6b11347e66437cd92dc20372d0abd6eb9 (patch)
tree6e42b5861278485c67159dc57c225983e3fd69f8 /client/app.jsx
parentd803aaaf1be441f55fe674c3b0c6793e77a9203f (diff)
downloadlocchat-84b45cd6b11347e66437cd92dc20372d0abd6eb9.tar.gz
locchat-84b45cd6b11347e66437cd92dc20372d0abd6eb9.zip
adds roles
Diffstat (limited to 'client/app.jsx')
-rw-r--r--client/app.jsx15
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>
);