SHARE
TWEET

Untitled

a guest Apr 27th, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const session = require('express-session');
  2.  
  3. /* Вся эта  история служит для автоматич. сохранения сессий в БД */
  4. const MongoStore = require('connect-mongo')(session);
  5. const connection = mongoose.createConnection(dataSecret.dbConfig.connectString); // === mongoose.connect(~)
  6.  
  7. app.use(session({
  8.     secret: dataSecret.cookieSecret,
  9.     store: new MongoStore({ mongooseConnection: connection })
  10. }));
  11.  
  12.  
  13. /* use */
  14. console.log('Текущая сессия' + req.session.userName)
  15.  
  16.         /*
  17.         Users.find({
  18.             name : req.body.name,
  19.             password : req.body.pass
  20.         },(err,data) => {
  21.            
  22.             if(err) { res.status(401).send('Не авторизован') }
  23.                 else{
  24.                     console.log('Попали в найденного челика')
  25.                     req.session.userName = req.body.name;
  26.                     console.log(req.session.userName);
  27.                     res.redirect('/')
  28.                 }
  29.         });
  30.     } */
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