make AllowUnregisteredUsers work on BB also

This commit is contained in:
Martin Michelsen
2022-07-01 22:17:37 -07:00
parent f823c2b907
commit d5308449e3
2 changed files with 19 additions and 8 deletions
+12 -4
View File
@@ -5,6 +5,7 @@
#include <memory>
#include <phosg/Filesystem.hh>
#include <phosg/Hash.hh>
#include <phosg/Network.hh>
#include <phosg/Random.hh>
#include <phosg/Strings.hh>
@@ -331,10 +332,17 @@ void process_login_bb(shared_ptr<ServerState> s, shared_ptr<Client> c,
auto l = s->license_manager->verify_bb(cmd.username, cmd.password);
c->set_license(l);
} catch (const exception& e) {
u16string message = u"Login failed: " + decode_sjis(e.what());
send_message_box(c, message.c_str());
c->should_disconnect = true;
return;
if (!s->allow_unregistered_users) {
u16string message = u"Login failed: " + decode_sjis(e.what());
send_message_box(c, message.c_str());
c->should_disconnect = true;
return;
} else {
shared_ptr<License> l = LicenseManager::create_license_bb(
fnv1a32(cmd.username), cmd.username, cmd.password, true);
s->license_manager->add(l);
c->set_license(l);
}
}
try {
+7 -4
View File
@@ -141,10 +141,13 @@
},
// By default, the server only allows users who are registered in the license
// file to connect. By enabling this option, all non-BB users will be allowed
// to connect. This option has no effect for Blue Burst clients; they are
// always required to be registered before connecting. Keep in mind that
// unregistered users cannot be banned!
// file to connect. By enabling this option, all users will be allowed to
// connect. Each time a user connects with an unregistered license (serial
// number / access key combination, or username/password combination on BB), a
// temporary license is created for them, which lasts until the server is
// shut down. This license is not saved to the license file. For BB, player
// and account data is still saved on the server, even for users with
// temporary licenses.
"AllowUnregisteredUsers": false,
// User to run the server as. If present, newserv will attempt to switch to