Browse Source

Show a notice when the user doesn't have a password.

pull/6/head
t123yh 7 years ago
parent
commit
8c52dd42de
  1. 1
      modules/api.js
  2. 3
      views/login.ejs

1
modules/api.js

@ -36,6 +36,7 @@ app.post('/api/login', async (req, res) => {
let user = await User.fromName(req.body.username); let user = await User.fromName(req.body.username);
if (!user) res.send({ error_code: 1001 }); if (!user) res.send({ error_code: 1001 });
else if (user.password == null || user.password === '') res.send({ error_code: 1003 });
else if (user.password !== req.body.password) res.send({ error_code: 1002 }); else if (user.password !== req.body.password) res.send({ error_code: 1002 });
else { else {
req.session.user_id = user.id; req.session.user_id = user.id;

3
views/login.ejs

@ -73,6 +73,9 @@ function login() {
case 1002: case 1002:
show_error("密码错误"); show_error("密码错误");
break; break;
case 1003:
show_error("您尚未设置密码,请通过下方「找回密码」来设置您的密码。");
break;
case 1: case 1:
success(data.session_id); success(data.session_id);
return; return;

Loading…
Cancel
Save