Created
November 26, 2017 18:22
-
-
Save DomDumont/3dce2829e9789ac5578503244a863768 to your computer and use it in GitHub Desktop.
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
const HEADER_REGEX = /bearer token-(.*)$/; | |
/** | |
* This is an extremely simple token. In real applications make | |
* sure to use a better one, such as JWT (https://jwt.io/). | |
*/ | |
module.exports.authenticate = async ({headers: {authorization}}, Users) => { | |
const email = authorization && HEADER_REGEX.exec(authorization)[1]; | |
return email && await Users.findOne({email}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment