feat: add computer name-based silent login (无感登录)

Implement automatic authentication based on computer name to enable
passwordless login for registered computers with fallback to manual
authentication.

Changes:
- Add SessionManager.login_by_computer_name() for silent login attempt
- Add BIPUsersDAO.authenticate_by_computer_name() for computer name lookup
- Update BIPUsersDAO.create_user() to support optional computer_name parameter
- Update main_ui.py to try silent login before showing login dialog
- Display current computer name in login dialog for user reference

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-02-10 16:44:47 +08:00
parent 7264fdc71a
commit 6d81d5cb76
3 changed files with 101 additions and 14 deletions

View File

@@ -63,6 +63,28 @@ class SessionManager:
return True
return False
def login_by_computer_name(self) -> bool:
"""
Attempt silent login using computer name
Returns:
True if login successful, False otherwise
"""
import socket
from db.bip_users_dao import BIPUsersDAO
computer_name = socket.gethostname()
dao = BIPUsersDAO()
user_info = dao.authenticate_by_computer_name(computer_name)
if user_info:
self._current_user = {
'username': user_info['username'],
'user_type': user_info['user_type']
}
return True
return False
def logout(self):
"""Logout the current user and clear session"""
self._current_user = None