Created
January 29, 2016 20:50
-
-
Save anomaly44/bfd12ef01f551b775e49 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
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