Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. app.post('/login', (req, res) => {
  2. // hash the password
  3. hash(req.password, (err, hashedPassword) => {
  4. if (err) {
  5. throw new Error(err.message);
  6. }
  7.  
  8. // find combination of username and password in db
  9. User.find({ username: req.username, password: hashedPassword }, (err, user) => {
  10. if (err) {
  11. throw new Error(err.message);
  12. }
  13.  
  14. // save session to redis
  15. redis.hget(user.id, (err, session) => {
  16. if (err) {
  17. throw new Error(err.message);
  18. }
  19.  
  20. // load user information after session is succesfully saved
  21. Transaction.find({ userId: user.id }, (err, transaction) => {
  22. return transaction;
  23. });
  24. });
  25. });
  26. });
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement