diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index f5fd8308..1933c8de 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -443,6 +443,9 @@ void MainWindow::registerError(Response::ResponseCode r, QString reasonStr, quin case Response::RespEmailRequiredToRegister: QMessageBox::critical(this, tr("Registration denied"), tr("It's mandatory to specify a valid email address when registering.")); break; + case Response::RespEmailBlackListed: + QMessageBox::critical(this, tr("Registration denied"), tr("The email address provider used during registration has been blacklisted for use on this server.")); + break; case Response::RespTooManyRequests: QMessageBox::critical(this, tr("Registration denied"), tr("Too many registration attempts, please try again later or contact the server operator for further details.")); break; diff --git a/common/pb/response.proto b/common/pb/response.proto index 4648bb38..0768c64f 100644 --- a/common/pb/response.proto +++ b/common/pb/response.proto @@ -39,6 +39,7 @@ message Response { RespClientIdRequired = 34; // Server requires client to generate and send its client id before allowing access RespClientUpdateRequired = 35; // Client is missing features that the server is requiring RespServerFull = 36; // Server user limit reached + RespEmailBlackListed = 37; // Server has blacklisted the email address provided for registration } enum ResponseType { JOIN_ROOM = 1000; diff --git a/servatrice/servatrice.ini.example b/servatrice/servatrice.ini.example index 75bb33a4..e2f7530c 100644 --- a/servatrice/servatrice.ini.example +++ b/servatrice/servatrice.ini.example @@ -144,6 +144,13 @@ disallowedregexp="" ; using the same email address. 0 = Unlimited number of accounts (default). ;maxaccountsperemail=0 +; You can prevent users from using certain mail domains for registration. This setting contains a +; comma-seperated list of email provider domains that you would like to prevent users from using +; during registration. Comparison's are implicit, so placing an entry such as mail.com will also +; prevent users from registering accounts with providers such as gmail.com and hotmail.com +; Example: "10minutemail.com,gmail.com" +;emailproviderblacklist="" + [smtp] ; Enable the internal smtp client to send registration emails. If you would like to diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index e3c77086..5895fdf0 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -240,6 +240,8 @@ bool Servatrice::initServer() qDebug() << "Accept registered users only: " << getRegOnlyServerEnabled(); qDebug() << "Registration enabled: " << getRegistrationEnabled(); if (getRegistrationEnabled()) { + QStringList emailBlackListFilters = getEmailBlackList().split(",", QString::SkipEmptyParts); + qDebug() << "Email blacklist: " << emailBlackListFilters; qDebug() << "Require email address to register: " << getRequireEmailForRegistrationEnabled(); qDebug() << "Require email activation via token: " << getRequireEmailActivationEnabled(); if (getMaxAccountsPerEmail()) { qDebug() << "Maximum number of accounts per email: " << getMaxAccountsPerEmail(); } else { qDebug() << "Maximum number of accounts per email: unlimited"; } @@ -843,4 +845,8 @@ int Servatrice::getMaxAccountsPerEmail() const { bool Servatrice::getEnableInternalSMTPClient() const { return settingsCache->value("smtp/enableinternalsmtpclient", true).toBool(); +} + +QString Servatrice::getEmailBlackList() const { + return settingsCache->value("registration/emailproviderblacklist").toString(); } \ No newline at end of file diff --git a/servatrice/src/servatrice.h b/servatrice/src/servatrice.h index 4eb2e17e..b7dbf827 100644 --- a/servatrice/src/servatrice.h +++ b/servatrice/src/servatrice.h @@ -180,6 +180,7 @@ public: QString getAuthenticationMethodString() const; QString getDBTypeString() const; QString getDbPrefix() const { return dbPrefix; } + QString getEmailBlackList() const; AuthenticationMethod getAuthenticationMethod() const { return authenticationMethod; } bool permitUnregisteredUsers() const { return authenticationMethod != AuthenticationNone; } bool getGameShouldPing() const { return true; } diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index dcfecd94..ae130b5e 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -881,7 +881,19 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C if (!registrationEnabled) return Response::RespRegistrationDisabled; + QString emailBlackList = servatrice->getEmailBlackList(); QString emailAddress = QString::fromStdString(cmd.email()); + QStringList emailBlackListFilters = emailBlackList.split(",", QString::SkipEmptyParts); + + // verify that users email/provider is not blacklisted + if (!emailBlackList.trimmed().isEmpty()) { + foreach(QString blackListEmailAddress, emailBlackListFilters) { + if (emailAddress.contains(blackListEmailAddress, Qt::CaseInsensitive)) { + return Response::RespEmailBlackListed; + } + } + } + bool requireEmailForRegistration = settingsCache->value("registration/requireemail", true).toBool(); if (requireEmailForRegistration) {