Last active
April 5, 2022 17:30
-
-
Save polluterofminds/a03110e485f0e74e407fdb10aa550239 to your computer and use it in GitHub Desktop.
Members Only Step 5
This file contains hidden or 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
async authorize(credentials) { | |
try { | |
const siwe = new SiweMessage(JSON.parse(credentials?.message || "{}")) | |
const domain = process.env.DOMAIN | |
if (siwe.domain !== domain) { | |
return null | |
} | |
if (siwe.nonce !== (await getCsrfToken({ req }))) { | |
return null | |
} | |
await siwe.validate(credentials?.signature || ""); | |
const ownsNFT = await validateNFTOwnership(siwe.address); | |
if(!ownsNFT) { | |
return null | |
} | |
return { | |
id: siwe.address | |
} | |
} catch (e) { | |
return null | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment