Skip to content

Commit

Permalink
feat: check permission util (#284)
Browse files Browse the repository at this point in the history
* chore: add jsonwebtoken

* feat: add permission check

* chore: use permissions as an array

* chore: remove jsonwebtoken

* feat: get verified permission

* chore: remove console log
  • Loading branch information
120EE0692 authored Oct 20, 2022
1 parent 8184b28 commit 0258824
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions client/src/utils/getAccess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { parseCookies } from 'nookies';

export default async function getAccess(ctx, permissions) {
if (!ctx || !permissions) return false;
try {
const cookies = parseCookies(ctx);
const { data, error } = await fetch(
process.env.NODE_ENV === 'production'
? 'https://mm.dashnet.in/api/auth/check'
: 'http://localhost:5000/auth/check',
{
method: 'GET',
mode: 'cors',
cache: 'no-cache',
headers: {
authorization: cookies.firebaseToken,
},
},
);
if (error) {
throw error;
}
return data;
} catch (error) {
throw error;
}
}

0 comments on commit 0258824

Please sign in to comment.