Last active
July 21, 2016 16:06
-
-
Save benjick/74984ab7bceadbf0a13264b945b23bc8 to your computer and use it in GitHub Desktop.
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
User.defineStatic('validate', async function validateUser(email, password) { | |
const user = await User.getAll(email, { index: 'email' }).run(); | |
if (user.length !== 1) { | |
throw new Error('No user found'); | |
} | |
if (!compare(password, user[0].password)) { | |
throw new Error('Wrong password'); | |
} | |
return true; | |
}); | |
const valid = await User.validate('[email protected]', 'hejsan123'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment