Skip to content

Instantly share code, notes, and snippets.

@Kernix13
Last active March 30, 2024 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kernix13/965c5411d2c05008bd61c81cb93576c0 to your computer and use it in GitHub Desktop.
Save Kernix13/965c5411d2c05008bd61c81cb93576c0 to your computer and use it in GitHub Desktop.
Check for server cookie
// Setting cookie for logged in admin
// run npm install cookie then:
// petadoption is the name of the cookie for this example
const cookie = require('cookie');
function isAdmin(event) {
const incomingCookie = cookie.parse(event.headers.cookie || '');
if (incomingCookie?.petadoption == 'apsodifugyhtjrkelwqzmxncbv0918273645') {
return true;
}
return false;
}
module.exports = isAdmin;
// then require and check if(isAdmin(event)) is any admin file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment