Я пытаюсь использовать паспорт со стратегией Google, но я получаю req.user не определен.Это мой index.js:
...
// pass passport for configuration
require('./config/passport.js')(passport);
//load all controllers and routes
load('controllers')
.then('routes')
.into(app);
//define port
const port = process.env.PORT || 3011;
// set views for error and 404 pages
app.set('views', __dirname + '/views');
var db_options = {
host : process.env.MYSQL_HOST,
user : process.env.MYSQL_USER,
password : process.env.MYSQL_PASSWORD,
database : process.env.MYSQL_DB
};
//connect with database
var connection = mysql.createConnection(db_options);
connection.connect();
var sessionStore = new mysqlStore({}, connection);
//set public folder
app.use(express.static(__dirname+'/public'));
app.use(flash()); // use connect-flash for flash messages stored in session
// read cookies (needed for auth)
app.use(cookieParser('abc'));
// get information from html forms
app.use(bodyParser());
//set session
// app.set('trust proxy', 1); // trust first proxy
app.use(session({
secret: 'abc',
cookie: { maxAge: 3600000 },
resave: true,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
..
Я проверил этот вопрос, но ни одно из решений не решено.