pccs v1.0: login at a1b2c3d4e5.dspy + cleanup

This commit is contained in:
yumoqing 2026-08-12 10:40:06 +08:00
parent 60f1adbe01
commit df727b43b7
2 changed files with 1 additions and 27 deletions

View File

@ -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/gateway.dspy',{method:'POST',body:fd});
var r=await fetch('/pccs/api/a1b2c3d4e5.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||'登录失败'

View File

@ -1,26 +0,0 @@
# pccs login
import hashlib as _hl, datetime as _dt
username = params_kw.get('username', '')
password = params_kw.get('password', '') or params_kw.get('passwd', '')
if not username or not password:
return {'status': 'error', 'message': '请输入用户名和密码'}
db = DBPools()
async with db.sqlorContext('pccs') as sor:
recs = await sor.R('users', {'username': username})
if not recs:
return {'status': 'error', 'message': '用户名或密码错误'}
user = recs[0]
pw_hash = _hl.sha256(password.encode()).hexdigest()
if pw_hash != (user.password or ''):
return {'status': 'error', 'message': '用户名或密码错误'}
await sor.U('users', {'id': user.id}, {
'last_login': _dt.datetime.now().isoformat(), 'login_fail_count': 0
})
return {
'status': 'ok', 'message': '登录成功',
'user': {'id': user.id, 'username': user.username,
'nick_name': user.nick_name or user.username}
}