Add role checks (#21)

* Add role checks

* Remove moved Roles enum
This commit is contained in:
John Wu
2021-03-22 11:29:35 -07:00
committed by GitHub
parent 03de4f5826
commit aea873e920
19 changed files with 1305 additions and 893 deletions

14
src/utils/jwt.js Normal file
View File

@@ -0,0 +1,14 @@
export const parsePayload = (token) => {
if (!token) return null;
const parts = token.split(".");
if (parts.length < 2) return null;
return JSON.parse(decode(parts[1]));
};
export const decode = (payload) => {
const l = (payload.length % 4);
if (l > 0) {
payload += "=".repeat(4 - l);
}
return atob(payload);
};