Skip to content

Instantly share code, notes, and snippets.

@benjick
Last active July 21, 2016 16:06
Show Gist options
  • 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('[email protected]', 'hejsan123');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment