SHARE
TWEET

NoSQL

a guest Oct 17th, 2019 145 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.use(bodyParser.json());
  2. app.use(bodyParser.urlencoded({ extended: false }));
  3.  
  4. app.post('/login', (req, res) => {
  5.   const user = req.body.username;
  6.   const pass = req.body.password;
  7.  
  8.   if (!user || !pass){
  9.     return res.send("One or more fields were not provided.");
  10.   }
  11.   const query = {
  12.     username: user,
  13.     password: pass
  14.   }
  15.  
  16.   User.findOne(query, function (err, user) {
  17.     if (!user){
  18.       res.send("Wrong username or password");
  19.       return
  20.     }
  21.  
  22.     res.send(process.env.FLAG);
  23.   });
  24. });
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