я использую admin-bro для моего администратора, он работает нормально, пока я не попытаюсь использовать его аутентификацию, когда я пытаюсь войти в систему с помощью панели администратора формы admin-bro, он просто продолжает загружаться без ответа, мой терминал говорит
express -сессия устарела, неопределенная опция восстановления; предоставить опцию восстановления node_modules / admin-bro-expressjs / plugin. js: 138: 14
express -сессия устарела не определена опция saveUninitialized; предоставить опцию saveUninitialized node_modules / admin-bro-expressjs / plugin. js: 138: 14 AdminBro: пакет готов, мы подключены!
вот мое приложение. js file
require('dotenv').config();
const express = require('express');
const engine = require('ejs-mate');
const path = require('path');
const favicon = require('serve-favicon');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const passport = require('passport');
const User = require('./models/user');
//const formidableMiddleware = require('express-formidable');
const session = require('express-session');
const mongoose = require('mongoose');
const methodOverride = require('method-override');
// const seedPosts = require('./seeds');
// seedPosts();
// require routes
const index = require('./routes/index');
const posts = require('./routes/posts');
const reviews = require('./routes/reviews');
const adminRouter= require('./routes/admin.router');
const app = express();
//connect to database
//var url = process.env.DATABASEURL || "mongodb://localhost:27017/surf-shop"
mongoose.connect("mongodb://localhost:27017/surf-shop" , {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
});
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', () => {
console.log('we\'re connected!');
});
// use ejs-locals for all ejs templates:
app.engine('ejs', engine);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// set public assets directory
app.use(express.static('public'));
//app.use(favicon(path.join(__dirname, 'public', 'favi.jpg')));
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(methodOverride('_method'));
// Configure Passport and Sessions
app.use(session({
secret: 'hang ten dude!',
resave: false,
saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
passport.use(User.createStrategy());
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
// set local variables middleware
app.use(function(req, res, next) {
// req.user = {
// // '_id' : '5bb27cd1f986d278582aa58c',
// // '_id' : '5bc521c0b142b6d7f7523406',
// '_id' : '5bfed10ad176f845e38aec92',
// 'username' : 'ian3'
// }
res.locals.currentUser = req.user;
// set default page title
res.locals.title = 'Surf Shop';
// set success flash message
res.locals.success = req.session.success || '';
delete req.session.success;
// set error flash message
res.locals.error = req.session.error || '';
delete req.session.error;
// continue on to next function in middleware chain
next();
});
// Mount routes
app.use('/', index);
app.use('/posts', posts);
app.use('/posts/:id/reviews', reviews);
app.use('/admin', adminRouter);
//app.use(formidableMiddleware());
// catch 404 and forward to error handler
app.use(function(req, res, next) {
const err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handler
app.use(function(err, req, res, next) {
// // set locals, only providing error in development
// res.locals.message = err.message;
// res.locals.error = req.app.get('env') === 'development' ? err : {};
// // render the error page
// res.status(err.status || 500);
// res.render('error');
console.log(err);
req.session.error = err.message;
res.redirect('back');
});
module.exports = app;
вот мой admin.route. js file
const AdminBro = require('admin-bro');
const AdminBroExpress = require('admin-bro-expressjs');
const AdminBroMongoose = require('admin-bro-mongoose');
const mongoose = require('mongoose');
AdminBro.registerAdapter(AdminBroMongoose);
const adminBro = new AdminBro({
databases: [mongoose],
rootPath: '/admin',
});
const ADMIN = {
email: process.env.ADMIN_EMAIL || 'admin@example.com',
password: process.env.ADMIN_PASSWORD || 'lovejs',
}
const router = AdminBroExpress.buildAuthenticatedRouter(adminBro, {
cookieName: process.env.ADMIN_COOKIE_NAME || 'admin-bro',
cookiePassword: process.env.ADMIN_COOKIE_PASS || 'some-super-sensitive-password',
authenticate: async (email, password) => {
if (ADMIN.password === password && ADMIN.email === email) {
return ADMIN
}
return null
}
});
module.exports = router;
любая помощь будет оценена