mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
removed usewebapi
This commit is contained in:
parent
5e0948ea93
commit
b67a0b6946
@ -14,8 +14,6 @@ acceptallcustomnames=true
|
|||||||
# how often should everything be flushed to the database?
|
# how often should everything be flushed to the database?
|
||||||
# the default is 4 minutes
|
# the default is 4 minutes
|
||||||
dbsaveinterval=240
|
dbsaveinterval=240
|
||||||
# use the web API
|
|
||||||
usewebapi=false
|
|
||||||
|
|
||||||
# Shard Server configuration
|
# Shard Server configuration
|
||||||
[shard]
|
[shard]
|
||||||
|
@ -53,21 +53,14 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::unique_ptr<Database::Account> findUser = Database::findAccount(userLogin);
|
std::unique_ptr<Database::Account> findUser = Database::findAccount(userLogin);
|
||||||
// if account not found
|
// if account not found, make new one
|
||||||
if (findUser == nullptr)
|
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] = CNLoginData();
|
||||||
loginSessions[sock].userID = Database::addAccount(userLogin, userPassword);
|
loginSessions[sock].userID = Database::addAccount(userLogin, userPassword);
|
||||||
loginSessions[sock].slot = 1;
|
loginSessions[sock].slot = 1;
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// if user exists, check if password is correct
|
// if user exists, check if password is correct
|
||||||
else if (CNLoginServer::isPasswordCorrect(findUser->Password, userPassword))
|
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) {
|
bool CNLoginServer::isLoginDataGood(std::string login, std::string password) {
|
||||||
std::regex loginRegex("[a-zA-Z0-9_-]{4,32}");
|
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}");
|
std::regex passwordRegex("[a-zA-Z0-9!@#$%^&*()_+]{8,32}");
|
||||||
|
|
||||||
return (std::regex_match(login, loginRegex) && std::regex_match(password, passwordRegex));
|
return (std::regex_match(login, loginRegex) && std::regex_match(password, passwordRegex));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNLoginServer::isPasswordCorrect(std::string actualPassword, std::string tryPassword) {
|
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);
|
return BCrypt::validatePassword(tryPassword, actualPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ int settings::VERBOSITY = 1;
|
|||||||
|
|
||||||
int settings::LOGINPORT = 8001;
|
int settings::LOGINPORT = 8001;
|
||||||
bool settings::APPROVEALLNAMES = true;
|
bool settings::APPROVEALLNAMES = true;
|
||||||
bool settings::USEWEBAPI = false;
|
|
||||||
int settings::DBSAVEINTERVAL = 240;
|
int settings::DBSAVEINTERVAL = 240;
|
||||||
|
|
||||||
int settings::SHARDPORT = 8002;
|
int settings::SHARDPORT = 8002;
|
||||||
@ -42,7 +41,6 @@ void settings::init() {
|
|||||||
APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES);
|
APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES);
|
||||||
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
|
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
|
||||||
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
||||||
USEWEBAPI = reader.GetBoolean("login", "usewebapi", USEWEBAPI);
|
|
||||||
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
||||||
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
|
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
|
||||||
DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL);
|
DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL);
|
||||||
|
@ -4,7 +4,6 @@ namespace settings {
|
|||||||
extern int VERBOSITY;
|
extern int VERBOSITY;
|
||||||
extern int LOGINPORT;
|
extern int LOGINPORT;
|
||||||
extern bool APPROVEALLNAMES;
|
extern bool APPROVEALLNAMES;
|
||||||
extern bool USEWEBAPI;
|
|
||||||
extern int DBSAVEINTERVAL;
|
extern int DBSAVEINTERVAL;
|
||||||
extern int SHARDPORT;
|
extern int SHARDPORT;
|
||||||
extern std::string SHARDSERVERIP;
|
extern std::string SHARDSERVERIP;
|
||||||
|
Loading…
Reference in New Issue
Block a user