统一身份认证系统




class User:
def __init__(self, username, password):
self.username = username
self.password = password
class AuthService:
def __init__(self):
self.users = []
def register_user(self, user):
self.users.append(user)
def authenticate(self, username, password):
for user in self.users:
if user.username == username and user.password == password:
return True
return False
# 示例使用
auth_service = AuthService()
user1 = User("alice", "password123")
auth_service.register_user(user1)
print(auth_service.authenticate("alice", "password123")) # 输出True
]]>