Add config option to disable automatic account creation

Also moved the acceptallcustomnames setting to the login section where
it belongs.
This commit is contained in:
dongresource 2022-06-29 23:42:44 +02:00
parent abda9dc158
commit 63d4087488
4 changed files with 14 additions and 4 deletions

View File

@ -14,6 +14,9 @@ sandbox=true
port=23000
# will all custom names be approved instantly?
acceptallcustomnames=true
# should attempts to log into non-existent accounts
# automatically create them?
autocreateaccounts=true
# how often should everything be flushed to the database?
# the default is 4 minutes
dbsaveinterval=240

View File

@ -133,8 +133,12 @@ void CNLoginServer::login(CNSocket* sock, CNPacketData* data) {
Database::findAccount(&findUser, userLogin);
// account was not found
if (findUser.AccountID == 0)
return newAccount(sock, userLogin, userPassword, login->iClientVerC);
if (findUser.AccountID == 0) {
if (settings::AUTOCREATEACCOUNTS)
return newAccount(sock, userLogin, userPassword, login->iClientVerC);
return loginFail(LoginError::ID_DOESNT_EXIST, userLogin, sock);
}
if (!CNLoginServer::isPasswordCorrect(findUser.Password, userPassword))
return loginFail(LoginError::ID_AND_PASSWORD_DO_NOT_MATCH, userLogin, sock);

View File

@ -11,6 +11,7 @@ bool settings::SANDBOX = true;
int settings::LOGINPORT = 23000;
bool settings::APPROVEALLNAMES = true;
bool settings::AUTOCREATEACCOUNTS = true;
int settings::DBSAVEINTERVAL = 240;
int settings::SHARDPORT = 23001;
@ -76,12 +77,13 @@ void settings::init() {
return;
}
APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES);
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
SANDBOX = reader.GetBoolean("", "sandbox", SANDBOX);
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
APPROVEALLNAMES = reader.GetBoolean("login", "acceptallcustomnames", APPROVEALLNAMES);
AUTOCREATEACCOUNTS = reader.GetBoolean("login", "autocreateaccounts", AUTOCREATEACCOUNTS);
DBSAVEINTERVAL = reader.GetInteger("login", "dbsaveinterval", DBSAVEINTERVAL);
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
SHARDSERVERIP = reader.Get("shard", "ip", SHARDSERVERIP);
LOCALHOSTWORKAROUND = reader.GetBoolean("shard", "localhostworkaround", LOCALHOSTWORKAROUND);
TIMEOUT = reader.GetInteger("shard", "timeout", TIMEOUT);

View File

@ -5,6 +5,7 @@ namespace settings {
extern bool SANDBOX;
extern int LOGINPORT;
extern bool APPROVEALLNAMES;
extern bool AUTOCREATEACCOUNTS;
extern int DBSAVEINTERVAL;
extern int SHARDPORT;
extern std::string SHARDSERVERIP;