Merge pull request #1873 from ctrlaltca/serva_emailz
Servatrice: Split requireemail into requireemail and requireemailaction
This commit is contained in:
commit
41494b49dd
3 changed files with 15 additions and 7 deletions
|
@ -105,11 +105,14 @@ allowpunctuationprefix=false
|
|||
; Enable this feature? Default false.
|
||||
;enabled=false
|
||||
|
||||
; Require users to provide an email address in order to register. Newly registered users will receive an
|
||||
; activation token by email, and will be required to input back this token on cockatrice at the first login
|
||||
; to get their account activated. Default true.
|
||||
; Require users to provide an email address in order to register. Default true.
|
||||
;requireemail=true
|
||||
|
||||
; Require email activation. Newly registered users will receive an activation token by email,
|
||||
; and will be required to input back this token on cockatrice at the first login to get their
|
||||
; account activated. Default true.
|
||||
;requireemailactivation=true
|
||||
|
||||
[smtp]
|
||||
|
||||
; Connectin type: currently supported method are "tcp" and "ssl"; tls is autodetected if available
|
||||
|
|
|
@ -175,11 +175,15 @@ bool Servatrice::initServer()
|
|||
|
||||
bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool();
|
||||
bool requireEmailForRegistration = settingsCache->value("registration/requireemail", true).toBool();
|
||||
bool requireEmailActivation = settingsCache->value("registration/requireemailactivation", true).toBool();
|
||||
|
||||
qDebug() << "Accept registered users only: " << regServerOnly;
|
||||
qDebug() << "Registration enabled: " << registrationEnabled;
|
||||
if (registrationEnabled)
|
||||
{
|
||||
qDebug() << "Require email address to register: " << requireEmailForRegistration;
|
||||
qDebug() << "Require email activation via token: " << requireEmailActivation;
|
||||
}
|
||||
|
||||
FeatureSet features;
|
||||
features.initalizeFeatureList(serverRequiredFeatureList);
|
||||
|
@ -498,8 +502,8 @@ void Servatrice::statusUpdate()
|
|||
|
||||
// send activation emails
|
||||
bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool();
|
||||
bool requireEmailForRegistration = settingsCache->value("registration/requireemail", true).toBool();
|
||||
if (registrationEnabled && requireEmailForRegistration)
|
||||
bool requireEmailActivation = settingsCache->value("registration/requireemailactivation", true).toBool();
|
||||
if (registrationEnabled && requireEmailActivation)
|
||||
{
|
||||
QSqlQuery *query = servatriceDatabaseInterface->prepareQuery("select a.name, b.email, b.token from {prefix}_activation_emails a left join {prefix}_users b on a.name = b.name");
|
||||
if (!servatriceDatabaseInterface->execSqlQuery(query))
|
||||
|
|
|
@ -1034,12 +1034,13 @@ Response::ResponseCode ServerSocketInterface::cmdRegisterAccount(const Command_R
|
|||
return Response::RespPasswordTooShort;
|
||||
|
||||
QString token;
|
||||
bool regSucceeded = sqlInterface->registerUser(userName, realName, gender, password, emailAddress, country, token, !requireEmailForRegistration);
|
||||
bool requireEmailActivation = settingsCache->value("registration/requireemailactivation", true).toBool();
|
||||
bool regSucceeded = sqlInterface->registerUser(userName, realName, gender, password, emailAddress, country, token, !requireEmailActivation);
|
||||
|
||||
if(regSucceeded)
|
||||
{
|
||||
qDebug() << "Accepted register command for user: " << userName;
|
||||
if(requireEmailForRegistration)
|
||||
if(requireEmailActivation)
|
||||
{
|
||||
QSqlQuery *query = sqlInterface->prepareQuery("insert into {prefix}_activation_emails (name) values(:name)");
|
||||
query->bindValue(":name", userName);
|
||||
|
|
Loading…
Reference in a new issue