Skip to content

Instantly share code, notes, and snippets.

@anomaly44
Created January 29, 2016 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anomaly44/bfd12ef01f551b775e49 to your computer and use it in GitHub Desktop.
Save anomaly44/bfd12ef01f551b775e49 to your computer and use it in GitHub Desktop.
static login(email, password) {
return Promise.try(() => Account.fetch(email))
.then(acc =>
bcrypt.compareAsync(password, acc.password)
.then(result => {
if (result) {
console.log(`User logged in: ${acc.email}`);
const token = jwt.sign(_.pick(acc, ['id', 'email', 'agencyId']),
process.env.JWT_SECRET, {expiresIn: 1440 * 60 * 11});
return {token};
}
throw new Error('Onjuist wachtwoord');
})
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment