daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Mar 19th, 2017 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. router.post('/login', function(req, res) {
  2.   var username = req.body['username'];
  3.   var pass = req.body['password'];
  4.  
  5.   db_users.check_credentials(username, pass)
  6.     .then(function (valid) {
  7.       if (!valid)
  8.         throw "Invalid username or password.";
  9.       return db_users.get_user_by_name(username);
  10.     })
  11.     .then(function (user) {
  12.       // add login stuff to our session
  13.       req.session.user_id = user.user_id;
  14.       req.session.username = user.username;
  15.       req.session.email = user.email;
  16.  
  17.       res.redirect('/');
  18.     })
  19.     .catch(function (errMsg) {
  20.       res.render('login', {login_error: errMsg, login_username: username});
  21.     });
  22. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top