diff --git a/wwwroot/index.html b/wwwroot/index.html
index 568416b..b09be93 100644
--- a/wwwroot/index.html
+++ b/wwwroot/index.html
@@ -102,7 +102,7 @@ async function doLogin(){
if(!u||!p){document.getElementById('login-msg').textContent='请输入用户名和密码';return}
var fd=new FormData();fd.append('username',u);fd.append('password',p);
try{
- var r=await fetch('/pccs/api/auth_login.dspy',{method:'POST',body:fd});
+ var r=await fetch('/pccs/api/pccs_login.dspy',{method:'POST',body:fd});
var d=await r.json();
if(d.status==='ok'){closeLogin();document.getElementById('login-msg').textContent=''}
else document.getElementById('login-msg').textContent=d.message||'登录失败'
diff --git a/wwwroot/pccs/api/auth_login.dspy b/wwwroot/pccs/api/pccs_login.dspy
similarity index 71%
rename from wwwroot/pccs/api/auth_login.dspy
rename to wwwroot/pccs/api/pccs_login.dspy
index a4260ac..19362ec 100644
--- a/wwwroot/pccs/api/auth_login.dspy
+++ b/wwwroot/pccs/api/pccs_login.dspy
@@ -1,4 +1,4 @@
-# pccs login — 使用 dspy 注入变量
+# pccs login endpoint
import hashlib as _hl, datetime as _dt
username = params_kw.get('username', '')
@@ -15,17 +15,14 @@ async with db.sqlorContext('pccs') as sor:
user = recs[0]
pw_hash = _hl.sha256(password.encode()).hexdigest()
- stored_pw = user.password or ''
-
- if pw_hash != stored_pw:
+ if pw_hash != (user.password or ''):
return {'status': 'error', 'message': '用户名或密码错误'}
- now = _dt.datetime.now().isoformat()
- await sor.U('users', {'id': user.id}, {'last_login': now, 'login_fail_count': 0})
-
+ await sor.U('users', {'id': user.id}, {
+ 'last_login': _dt.datetime.now().isoformat(), 'login_fail_count': 0
+ })
return {
- 'status': 'ok',
- 'message': '登录成功',
+ 'status': 'ok', 'message': '登录成功',
'user': {'id': user.id, 'username': user.username,
'nick_name': user.nick_name or user.username}
}