Skip to content

Instantly share code, notes, and snippets.

@benjick
Last active July 21, 2016 16:06
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 benjick/74984ab7bceadbf0a13264b945b23bc8 to your computer and use it in GitHub Desktop.
Save benjick/74984ab7bceadbf0a13264b945b23bc8 to your computer and use it in GitHub Desktop.
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('benjick@dumfan.net', 'hejsan123');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment