форма регистрации не работает, информация не отправляется в базу данных, я заполняю форму и отправляю ее, но я все еще получаю пустую базу данных.
это мой паспорт
var LocalStrategy = require("passport-local").Strategy;
var mysql = require('mysql');
var bcrypt = require('bcrypt-nodejs');
var dbconfig = require('./database');
var connection = mysql.createConnection(dbconfig.connection);
connection.query('USE ' + dbconfig.database);
// connection.connect(function(err) {
// if (err) console.log(err) ;
// console.log("Connected!");
// connection.query("CREATE DATABASE taggetDB", function (err, result) {
// if (err) console.log(err) ;
// console.log("Database created");
// });
// });
module.exports = function(passport) {
passport.serializeUser(function(user, done){
done(null, user.id);
});
passport.deserializeUser(function(id, done){
connection.query("SELECT * FROM users WHERE id = ? ", [id],
function(err, rows){
done(err, rows[0]);
});
});
passport.use(
'local-signup',
new LocalStrategy({
nameField : 'name',
emailField: 'email',
passwordField: 'password',
passReqToCallback: true
},
function(req, name, email, password, done){
connection.query("SELECT * FROM users WHERE name = ? ",
[name], function(err, rows){
if(err)
return done(err);
if(rows.length){
return done(null, false, req.flash('signupMessage', 'That is already taken'));
}else{
var newUserMysql = {
id:"2",
name: name,
email:email,
password: bcrypt.hashSync(password, null, null)
};
var insertQuery = "INSERT INTO users (name,email,password) values (?, ?, ?)";
connection.query(insertQuery, [newUserMysql.name, newUserMysql.email, newUserMysql.password],
function(err, rows){
newUserMysql.id = rows.insertId;
return done(null, newUserMysql);
});
}
});
})
);
passport.use(
'local-login',
new LocalStrategy({
emailField : 'email',
passwordField: 'password',
passReqToCallback: true
},
function(req, email, password, done){
connection.query("SELECT * FROM users WHERE email = ? ", [email],
function(err, rows){
if(err)
return done(err);
if(!rows.length){
return done(null, false, req.flash('loginMessage', 'No User Found'));
}
if(!bcrypt.compareSync(password, rows[0].password))
return done(null, false, req.flash('loginMessage', 'Wrong Password'));
return done(null, rows[0]);
});
})
);
};
это мой маршрут регистрации, получение и публикация
module.exports = function (app,passport) {
app.get('/signup', function (req, res) {
res.render('signup', { message: req.flash('signupMessage') });
});
app.post('/signup', passport.authenticate('local-signup', {
successRedirect: '/profile',
failureRedirect: '/signup',
failureFlash: true
}));
}
не уверен, в чем проблема, как только я заполняю детали в своей форме и отправляю форму, это то, что мой консоль выглядит так. там действительно нет ошибок, я не знаю
вот моя консоль
[nodemon] starting `node app.js`
listen is port 3000
GET /signup 200 36.869 ms - 2935
GET /assets/css/lib/bootstrap.min.css 304 7.705 ms - -
GET /assets/css/swipe.min.css 304 6.105 ms - -
GET /assets/css/js/app.js 304 4.768 ms - -
GET /assets/fonts/circular/CircularStd-Black.woff 404 4.150 ms - 183
GET /assets/fonts/circular/CircularStd-Book.woff 404 1.811 ms - 182
GET /assets/fonts/material/MaterialIcons-Regular.woff2 404 2.256 ms - 188
GET /assets/fonts/circular/CircularStd-Black.ttf 404 0.866 ms - 182
GET /assets/fonts/circular/CircularStd-Book.ttf 404 1.094 ms - 181
GET /assets/fonts/material/MaterialIcons-Regular.woff 404 1.245 ms - 187
GET /assets/fonts/material/MaterialIcons-Regular.ttf 404 1.546 ms - 186
POST /views/settings/setup 404 22.043 ms - 160
POST /views/settings/setup 404 2.430 ms - 160
GET /signup 200 9.697 ms - 2900
GET /assets/css/lib/bootstrap.min.css 304 1.600 ms - -
GET /assets/css/swipe.min.css 304 0.879 ms - -
GET /assets/css/js/app.js 304 0.923 ms - -
GET /assets/fonts/circular/CircularStd-Black.woff 404 1.410 ms - 183
GET /assets/fonts/circular/CircularStd-Book.woff 404 2.016 ms - 182
GET /assets/fonts/material/MaterialIcons-Regular.woff2 404 1.772 ms - 188
GET /assets/fonts/circular/CircularStd-Black.ttf 404 1.751 ms - 182
GET /assets/fonts/circular/CircularStd-Book.ttf 404 1.641 ms - 181
GET /assets/fonts/material/MaterialIcons-Regular.woff 404 2.555 ms - 187
GET /assets/fonts/material/MaterialIcons-Regular.ttf 404 1.621 ms - 186
POST /signup 302 10.518 ms - 58
GET /signup 200 7.417 ms - 2900
GET /assets/css/lib/bootstrap.min.css 304 1.970 ms - -
GET /assets/css/swipe.min.css 304 2.396 ms - -
GET /assets/css/js/app.js 304 2.358 ms - -
GET /assets/fonts/circular/CircularStd-Black.woff 404 2.535 ms - 183
GET /assets/fonts/circular/CircularStd-Book.woff 404 2.919 ms - 182
GET /assets/fonts/material/MaterialIcons-Regular.woff2 404 1.488 ms - 188
GET /assets/fonts/circular/CircularStd-Black.ttf 404 2.324 ms - 182
GET /assets/fonts/circular/CircularStd-Book.ttf 404 3.469 ms - 181
GET /assets/fonts/material/MaterialIcons-Regular.woff 404 2.598 ms - 187
GET /assets/fonts/material/MaterialIcons-Regular.ttf 404 1.605 ms - 186
пожалуйста, помогите мне.