Last active
March 30, 2024 18:12
-
-
Save Kernix13/965c5411d2c05008bd61c81cb93576c0 to your computer and use it in GitHub Desktop.
Check for server cookie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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