2026-04-16 13:41:15 +08:00

18 lines
721 B
Plaintext

# Login script that integrates with RBAC module
from rbac.check_perm import checkUserPassword
from appPublic.app import get_current_app
async def login_user(username, password):
"""Handle user login using RBAC authentication"""
try:
# Use RBAC's password checking function
user = await checkUserPassword(username, password)
if user:
# Set session user
app = get_current_app()
app.set_session_user(user)
return {"success": True, "redirect": "base.ui"}
else:
return {"success": False, "message": "用户名或密码错误"}
except Exception as e:
return {"success": False, "message": f"登录失败: {str(e)}"}