Add the secure login,the user must is blogger user.Thank for zhaojun1998.

dependabot/npm_and_yarn/mixin-deep-1.3.2
Autmaple 6 years ago
parent 752df89d01
commit 8b9049e498
  1. 17
      app.js

@ -46,13 +46,18 @@ app.use('/comments', require('./routes/comments'));
// 处理登录请求(可能来自登录界面中的表单)
app.post('/login', function(req, res) {
AV.User.logIn(req.body.username, req.body.password).then(function(user) {
res.saveCurrentUser(user); // 保存当前用户到 Cookie
res.redirect('/comments'); // 跳转到个人资料页面
}, function(error) {
//登录失败,跳转到登录页面
if (req.body.username == process.env.SMTP_USER || req.body.username == process.env.BLOGGER_EMAIL) {
AV.User.logIn(req.body.username, req.body.password).then(function(user) {
res.saveCurrentUser(user); // 保存当前用户到 Cookie
res.redirect('/comments'); // 跳转到个人资料页面
}, function(error) {
//登录失败,跳转到登录页面
res.redirect('/');
});
} else {
// 登录用户非博主,跳转到登录页面
res.redirect('/');
});
}
});
// 登出账号

Loading…
Cancel
Save