From b67a0b69463f0d0f45ab04949caecc8a0429512f Mon Sep 17 00:00:00 2001 From: CPunch Date: Mon, 21 Sep 2020 14:49:08 -0500 Subject: [PATCH] removed usewebapi --- config.ini | 2 -- src/CNLoginServer.cpp | 18 ++---------------- src/settings.cpp | 2 -- src/settings.hpp | 1 - 4 files changed, 2 insertions(+), 21 deletions(-) diff --git a/config.ini b/config.ini index 4349b2d..de43a05 100644 --- a/config.ini +++ b/config.ini @@ -14,8 +14,6 @@ acceptallcustomnames=true # how often should everything be flushed to the database? # the default is 4 minutes dbsaveinterval=240 -# use the web API -usewebapi=false # Shard Server configuration [shard] diff --git a/src/CNLoginServer.cpp b/src/CNLoginServer.cpp index 248115a..6bbb3cf 100644 --- a/src/CNLoginServer.cpp +++ b/src/CNLoginServer.cpp @@ -53,20 +53,13 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) { else { std::unique_ptr findUser = Database::findAccount(userLogin); - // if account not found + // if account not found, make new one if (findUser == nullptr) { - //web api takes care of registration - if (settings::USEWEBAPI) - errorCode = (int)LoginError::ID_DOESNT_EXIST; - //without web api, create new account - else - { loginSessions[sock] = CNLoginData(); loginSessions[sock].userID = Database::addAccount(userLogin, userPassword); loginSessions[sock].slot = 1; success = true; - } } // if user exists, check if password is correct else if (CNLoginServer::isPasswordCorrect(findUser->Password, userPassword)) @@ -429,19 +422,12 @@ bool CNLoginServer::exitDuplicate(int accountId) { bool CNLoginServer::isLoginDataGood(std::string login, std::string password) { std::regex loginRegex("[a-zA-Z0-9_-]{4,32}"); - //web api sends password hashed, so we don't check it - if (settings::USEWEBAPI) - return (std::regex_match(login, loginRegex)); - //without web api std::regex passwordRegex("[a-zA-Z0-9!@#$%^&*()_+]{8,32}"); + return (std::regex_match(login, loginRegex) && std::regex_match(password, passwordRegex)); } bool CNLoginServer::isPasswordCorrect(std::string actualPassword, std::string tryPassword) { - //web api sends password already hashed - if (settings::USEWEBAPI) - return actualPassword == tryPassword; - //without web api return BCrypt::validatePassword(tryPassword, actualPassword); } diff --git a/src/settings.cpp b/src/settings.cpp index e289ff9..9beadf6 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -7,7 +7,6 @@ int settings::VERBOSITY = 1; int settings::LOGINPORT = 8001; bool settings::APPROVEALLNAMES = true; -bool settings::USEWEBAPI = false; int settings::DBSAVEINTERVAL = 240; int settings::SHARDPORT = 8002; @@ -42,7 +41,6 @@ void settings::init() { APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES); VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY); LOGINPORT = reader.GetInteger("login", "port", LOGINPORT); - USEWEBAPI = reader.GetBoolean("login", "usewebapi", USEWEBAPI); SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT); SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1"); DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL); diff --git a/src/settings.hpp b/src/settings.hpp index 0a1f7b7..6700ab6 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -4,7 +4,6 @@ namespace settings { extern int VERBOSITY; extern int LOGINPORT; extern bool APPROVEALLNAMES; - extern bool USEWEBAPI; extern int DBSAVEINTERVAL; extern int SHARDPORT; extern std::string SHARDSERVERIP;