#include "include/auth.h" namespace meg { Auth::Auth() { // 小学 张三1..3 users_[L"张三1"] = {L"123", Level::Primary}; users_[L"张三2"] = {L"123", Level::Primary}; users_[L"张三3"] = {L"123", Level::Primary}; // 初中 李四1..3 users_[L"李四1"] = {L"123", Level::Middle}; users_[L"李四2"] = {L"123", Level::Middle}; users_[L"李四3"] = {L"123", Level::Middle}; // 高中 王五1..3 users_[L"王五1"] = {L"123", Level::High}; users_[L"王五2"] = {L"123", Level::High}; users_[L"王五3"] = {L"123", Level::High}; } std::optional Auth::authenticate(const std::wstring& username, const std::wstring& password) const { auto it = users_.find(username); if (it == users_.end()) return std::nullopt; if (it->second.first != password) return std::nullopt; return User{username, password, it->second.second}; } } // namespace meg