+
+bool Server::findUser(const RadProto::Packet& packet)
+{
+ std::string login;
+ std::string password;
+ for (const auto& attribute : packet.attributes())
+ {
+ if (attribute->type() == RadProto::USER_NAME)
+ login = attribute->toString();
+
+ if (attribute->type() == RadProto::USER_PASSWORD)
+ password = attribute->toString();
+ }
+
+ User* user = nullptr;
+ if (m_users->FindByName(login, &user))
+ {
+ m_logger("User '%s' not found.", login.c_str());
+ printfd(__FILE__, "User '%s' NOT found!\n", login.c_str());
+ return false;
+ }
+
+ printfd(__FILE__, "User '%s' FOUND!\n", user->GetLogin().c_str());
+
+ if (password != user->GetProperties().password.Get())
+ {
+ m_logger("User's password is incorrect. %s", password.c_str());
+ printfd(__FILE__, "User's password is incorrect.\n", password.c_str());
+ return false;
+ }
+ return true;
+}