node.js - flash nodejs不显示
问题描述
我不确定语法,但flash 显示不正确...
我使用express-flash-2,也尝试过其他库...
router.post('/changepassword',ensureAuthenticated, function(req, res){
if(req.body.newpwd == req.body.newpwdb){
db.query(SqlString.format("Select password FROM Userdata.users WHERE id=?",[req.user.id]), function(error, result){
if(bcrypt.compareSync(req.body.pwd, result[0].password)){
db.query(SqlString.format("SELECT * FROM Userdata.insecpwd WHERE password=?",[req.body.newpwd]), function(er,re){
if (!re[0]){
db.query(SqlString.format("SELECT salt FROM Userdata.salts WHERE userid=?",[req.user.id]), function(e,r){
if (e) throw e;
var hash = bcrypt.hashSync(req.body.newpwd, r[0].salt);
var sql = 'UPDATE Userdata.users SET password=? WHERE id =?';
db.query(SqlString.format(sql,[hash,req.user.id]),function(err,re){
if (err) throw err;
});
});
req.flash('msg','PWD changed');
}else {
req.flash('error','New PWD not secure enough');
}
});
}else{
req.flash('error','Old PWD incorrect');
}
});
}else{
req.flash('error','PWDS do not match');
}
res.redirect("/users/settings");
});
是代码错了,还是我用错了flash?谢谢
解决方案
推荐阅读
- javascript - 在地图中显示子模式的最佳方式?
- laravel - vue js 不是函数
- sql - 如何找到使用 SQL 中的函数计算计数的组的最大计数?
- angular - “FirebaseOriginal”类型不可分配给“Provider”类型。名称未找到问题
- php - 为什么 Doctrine Param_str_array 转换没有按预期工作?
- build - 是否可以创建一个 Windows 安装程序来结合使用 Electron 框架和 AutoHotkey 工具构建的应用程序?
- sql - 获得第二个最高分数和名称
- c - fprintf stderr segfaults 在它自己的线程中,在 main 中工作
- html - 在没有 nodeJS / Express 服务器的情况下跨 react 应用禁用 CORS / CORB
- android - 在运行时 Android Studio 上编译 cpp 文件