mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Expose the audit log on the database interface (#7835)
addAuditRecord existed only on Servatrice_DatabaseInterface, so 37 moderator and admin commands reached through the concrete class just to append a log row. Declare it on Server_DatabaseInterface with an empty default, mark the Servatrice implementation as an override, and switch the handler's call sites to the injected interface. No SQL moves; the argument hashes are unchanged.
This commit is contained in:
parent
7734a94f83
commit
417e7f7db4
4 changed files with 95 additions and 83 deletions
|
|
@ -248,6 +248,15 @@ public:
|
||||||
{
|
{
|
||||||
return DeckStorageResult::Failed;
|
return DeckStorageResult::Failed;
|
||||||
}
|
}
|
||||||
|
/** @brief Append a moderator/admin action to the server audit log. */
|
||||||
|
virtual void addAuditRecord(const QString & /* user */,
|
||||||
|
const QString & /* ipaddress */,
|
||||||
|
const QString & /* clientid */,
|
||||||
|
const QString & /* action */,
|
||||||
|
const QString & /* details */,
|
||||||
|
bool /* results */)
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual bool removeForgotPassword(const QString & /* user */)
|
virtual bool removeForgotPassword(const QString & /* user */)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -3320,7 +3320,7 @@ void Servatrice_DatabaseInterface::addAuditRecord(const QString &user,
|
||||||
const QString &clientid,
|
const QString &clientid,
|
||||||
const QString &action,
|
const QString &action,
|
||||||
const QString &details,
|
const QString &details,
|
||||||
const bool &results = false)
|
bool results)
|
||||||
{
|
{
|
||||||
if (!checkSql()) {
|
if (!checkSql()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ public:
|
||||||
const QString &clientid,
|
const QString &clientid,
|
||||||
const QString &action,
|
const QString &action,
|
||||||
const QString &details,
|
const QString &details,
|
||||||
const bool &results);
|
bool results) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2083,7 +2083,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdReportResolve(const Com
|
||||||
return Response::RespInvalidData;
|
return Response::RespInvalidData;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlInterface->addAuditRecord(QString::number(reportId), this->getAddress(),
|
databaseInterface->addAuditRecord(QString::number(reportId), this->getAddress(),
|
||||||
QString::fromStdString(userInfo->clientid()),
|
QString::fromStdString(userInfo->clientid()),
|
||||||
dismissed ? "REPORT_DISMISSED" : "REPORT_RESOLVED",
|
dismissed ? "REPORT_DISMISSED" : "REPORT_RESOLVED",
|
||||||
QString("Report #%1 %2").arg(reportId).arg(newStatus), true);
|
QString("Report #%1 %2").arg(reportId).arg(newStatus), true);
|
||||||
|
|
@ -2538,7 +2538,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdResetUserPassword(const
|
||||||
}
|
}
|
||||||
sqlInterface->setForcePasswordChange(userName, true);
|
sqlInterface->setForcePasswordChange(userName, true);
|
||||||
|
|
||||||
sqlInterface->addAuditRecord(userName, this->getAddress(), QString::fromStdString(userInfo->clientid()),
|
databaseInterface->addAuditRecord(userName, this->getAddress(), QString::fromStdString(userInfo->clientid()),
|
||||||
"PASSWORD_RESET", "Admin password reset", true);
|
"PASSWORD_RESET", "Admin password reset", true);
|
||||||
|
|
||||||
// Notify the affected user if they are currently online.
|
// Notify the affected user if they are currently online.
|
||||||
|
|
@ -2580,7 +2580,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRemoveUserAvatar(const
|
||||||
return Response::RespInternalError;
|
return Response::RespInternalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlInterface->addAuditRecord(userName, this->getAddress(), QString::fromStdString(userInfo->clientid()),
|
databaseInterface->addAuditRecord(userName, this->getAddress(), QString::fromStdString(userInfo->clientid()),
|
||||||
"REMOVE_USER_AVATAR", "Moderator removed user avatar", true);
|
"REMOVE_USER_AVATAR", "Moderator removed user avatar", true);
|
||||||
|
|
||||||
Response_RemoveUserAvatar *re = new Response_RemoveUserAvatar;
|
Response_RemoveUserAvatar *re = new Response_RemoveUserAvatar;
|
||||||
|
|
@ -2616,7 +2616,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRemoveUserBanner(const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hadBanner) {
|
if (hadBanner) {
|
||||||
sqlInterface->addAuditRecord(userName, this->getAddress(), QString::fromStdString(userInfo->clientid()),
|
databaseInterface->addAuditRecord(userName, this->getAddress(), QString::fromStdString(userInfo->clientid()),
|
||||||
"REMOVE_USER_BANNER", "Moderator removed user banner card", true);
|
"REMOVE_USER_BANNER", "Moderator removed user banner card", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2640,7 +2640,7 @@ AbstractServerSocketInterface::cmdClearBlacklistedBanners(const Command_ClearBla
|
||||||
return Response::RespInternalError;
|
return Response::RespInternalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlInterface->addAuditRecord(QString::fromStdString(userInfo->name()), this->getAddress(),
|
databaseInterface->addAuditRecord(QString::fromStdString(userInfo->name()), this->getAddress(),
|
||||||
QString::fromStdString(userInfo->clientid()), "CLEAR_BLACKLISTED_BANNERS",
|
QString::fromStdString(userInfo->clientid()), "CLEAR_BLACKLISTED_BANNERS",
|
||||||
QString("Moderator cleared %1 blacklisted banner(s)").arg(cleared), true);
|
QString("Moderator cleared %1 blacklisted banner(s)").arg(cleared), true);
|
||||||
|
|
||||||
|
|
@ -2837,8 +2837,9 @@ Response::ResponseCode AbstractServerSocketInterface::cmdReportReopen(const Comm
|
||||||
if (!note.isEmpty()) {
|
if (!note.isEmpty()) {
|
||||||
auditDetails += QString(". Reason: %1").arg(note.left(200));
|
auditDetails += QString(". Reason: %1").arg(note.left(200));
|
||||||
}
|
}
|
||||||
sqlInterface->addAuditRecord(QString::number(reportId), this->getAddress(),
|
databaseInterface->addAuditRecord(QString::number(reportId), this->getAddress(),
|
||||||
QString::fromStdString(userInfo->clientid()), "REPORT_REOPENED", auditDetails, true);
|
QString::fromStdString(userInfo->clientid()), "REPORT_REOPENED", auditDetails,
|
||||||
|
true);
|
||||||
|
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
}
|
}
|
||||||
|
|
@ -3127,7 +3128,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool();
|
bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool();
|
||||||
if (!registrationEnabled) {
|
if (!registrationEnabled) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Server functionality disabled", false);
|
"REGISTER_ACCOUNT", "Server functionality disabled", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3150,7 +3151,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
// If a whitelist exists, ensure the email address domain IS in the whitelist
|
// If a whitelist exists, ensure the email address domain IS in the whitelist
|
||||||
if (!emailWhiteListFilters.isEmpty() && !emailWhiteListFilters.contains(emailDomain, Qt::CaseInsensitive)) {
|
if (!emailWhiteListFilters.isEmpty() && !emailWhiteListFilters.contains(emailDomain, Qt::CaseInsensitive)) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Email used is not whitelisted", false);
|
"REGISTER_ACCOUNT", "Email used is not whitelisted", false);
|
||||||
}
|
}
|
||||||
auto *re = new Response_Register;
|
auto *re = new Response_Register;
|
||||||
|
|
@ -3163,7 +3164,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
// If a blacklist exists, ensure the email address domain is NOT in the blacklist
|
// If a blacklist exists, ensure the email address domain is NOT in the blacklist
|
||||||
if (!emailBlackListFilters.isEmpty() && emailBlackListFilters.contains(emailDomain, Qt::CaseInsensitive)) {
|
if (!emailBlackListFilters.isEmpty() && emailBlackListFilters.contains(emailDomain, Qt::CaseInsensitive)) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Email used is blacklisted", false);
|
"REGISTER_ACCOUNT", "Email used is blacklisted", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3174,7 +3175,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
QString errorString;
|
QString errorString;
|
||||||
if (!sqlInterface->usernameIsValid(userName, errorString)) {
|
if (!sqlInterface->usernameIsValid(userName, errorString)) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Username is invalid", false);
|
"REGISTER_ACCOUNT", "Username is invalid", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3186,7 +3187,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
|
|
||||||
if (userName.toLower().simplified() == "servatrice") {
|
if (userName.toLower().simplified() == "servatrice") {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Username is invalid", false);
|
"REGISTER_ACCOUNT", "Username is invalid", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3195,7 +3196,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
|
|
||||||
if (sqlInterface->userExists(userName)) {
|
if (sqlInterface->userExists(userName)) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Username already exists", false);
|
"REGISTER_ACCOUNT", "Username already exists", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3206,9 +3207,9 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
if (servatrice->getMaxAccountsPerEmail() > 0 &&
|
if (servatrice->getMaxAccountsPerEmail() > 0 &&
|
||||||
sqlInterface->checkNumberOfUserAccounts(parsedEmailAddress) >= servatrice->getMaxAccountsPerEmail()) {
|
sqlInterface->checkNumberOfUserAccounts(parsedEmailAddress) >= servatrice->getMaxAccountsPerEmail()) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Too many usernames registered with this email address",
|
"REGISTER_ACCOUNT",
|
||||||
false);
|
"Too many usernames registered with this email address", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::RespTooManyRequests;
|
return Response::RespTooManyRequests;
|
||||||
|
|
@ -3218,7 +3219,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
int banSecondsRemaining;
|
int banSecondsRemaining;
|
||||||
if (sqlInterface->checkUserIsBanned(this->getAddress(), userName, clientId, banReason, banSecondsRemaining)) {
|
if (sqlInterface->checkUserIsBanned(this->getAddress(), userName, clientId, banReason, banSecondsRemaining)) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "User is banned", false);
|
"REGISTER_ACCOUNT", "User is banned", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3233,7 +3234,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
|
|
||||||
if (tooManyRegistrationAttempts(this->getAddress())) {
|
if (tooManyRegistrationAttempts(this->getAddress())) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Too many registration attempts from this ip address",
|
"REGISTER_ACCOUNT", "Too many registration attempts from this ip address",
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
@ -3262,7 +3263,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
passwordNeedsHash = true;
|
passwordNeedsHash = true;
|
||||||
if (!isPasswordLongEnough(password.length())) {
|
if (!isPasswordLongEnough(password.length())) {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Password is too short", false);
|
"REGISTER_ACCOUNT", "Password is too short", false);
|
||||||
}
|
}
|
||||||
return Response::RespPasswordTooShort;
|
return Response::RespPasswordTooShort;
|
||||||
|
|
@ -3293,7 +3294,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
}
|
}
|
||||||
|
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "", true);
|
"REGISTER_ACCOUNT", "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3301,7 +3302,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "", true);
|
"REGISTER_ACCOUNT", "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3309,7 +3310,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"REGISTER_ACCOUNT", "Unknown reason for failure", false);
|
"REGISTER_ACCOUNT", "Unknown reason for failure", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3361,7 +3362,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdActivateAccount(const C
|
||||||
qCDebug(AbstractServerSocketInterfaceLog) << "Accepted activation for user" << userName;
|
qCDebug(AbstractServerSocketInterfaceLog) << "Accepted activation for user" << userName;
|
||||||
|
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"ACTIVATE_ACCOUNT", "", true);
|
"ACTIVATE_ACCOUNT", "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3370,9 +3371,9 @@ Response::ResponseCode AbstractServerSocketInterface::cmdActivateAccount(const C
|
||||||
qCDebug(AbstractServerSocketInterfaceLog) << "Failed activation for user" << userName;
|
qCDebug(AbstractServerSocketInterfaceLog) << "Failed activation for user" << userName;
|
||||||
|
|
||||||
if (servatrice->getEnableRegistrationAudit()) {
|
if (servatrice->getEnableRegistrationAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"ACTIVATE_ACCOUNT", "Failed to activate account, incorrect activation token",
|
"ACTIVATE_ACCOUNT",
|
||||||
false);
|
"Failed to activate account, incorrect activation token", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::RespActivationFailed;
|
return Response::RespActivationFailed;
|
||||||
|
|
@ -3688,8 +3689,9 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordRequest(c
|
||||||
|
|
||||||
if (servatrice->recordForgotPasswordAttempt(this->getAddress())) {
|
if (servatrice->recordForgotPasswordAttempt(this->getAddress())) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_REQUEST", "Too many requests from this ip address", false);
|
"PASSWORD_RESET_REQUEST", "Too many requests from this ip address",
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::RespTooManyRequests;
|
return Response::RespTooManyRequests;
|
||||||
|
|
@ -3697,7 +3699,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordRequest(c
|
||||||
|
|
||||||
if (!servatrice->getEnableForgotPassword()) {
|
if (!servatrice->getEnableForgotPassword()) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_REQUEST", "Server functionality disabled", false);
|
"PASSWORD_RESET_REQUEST", "Server functionality disabled", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3713,7 +3715,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordRequest(c
|
||||||
|
|
||||||
if (!sqlInterface->userExists(userName)) {
|
if (!sqlInterface->userExists(userName)) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_REQUEST", "User does not exist", false);
|
"PASSWORD_RESET_REQUEST", "User does not exist", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3731,7 +3733,7 @@ Response::ResponseCode AbstractServerSocketInterface::continuePasswordRequest(co
|
||||||
if (sqlInterface->doesForgotPasswordExist(userName)) {
|
if (sqlInterface->doesForgotPasswordExist(userName)) {
|
||||||
|
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_REQUEST", "Request already exists", true);
|
"PASSWORD_RESET_REQUEST", "Request already exists", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3745,7 +3747,7 @@ Response::ResponseCode AbstractServerSocketInterface::continuePasswordRequest(co
|
||||||
int banTimeRemaining;
|
int banTimeRemaining;
|
||||||
if (sqlInterface->checkUserIsBanned(this->getAddress(), userName, clientId, banReason, banTimeRemaining)) {
|
if (sqlInterface->checkUserIsBanned(this->getAddress(), userName, clientId, banReason, banTimeRemaining)) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_REQUEST", "User is banned", false);
|
"PASSWORD_RESET_REQUEST", "User is banned", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3754,7 +3756,7 @@ Response::ResponseCode AbstractServerSocketInterface::continuePasswordRequest(co
|
||||||
|
|
||||||
if (!sqlInterface->addForgotPassword(userName)) {
|
if (!sqlInterface->addForgotPassword(userName)) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_REQUEST", "Failed to create password reset", false);
|
"PASSWORD_RESET_REQUEST", "Failed to create password reset", false);
|
||||||
}
|
}
|
||||||
return Response::RespFunctionNotAllowed;
|
return Response::RespFunctionNotAllowed;
|
||||||
|
|
@ -3763,7 +3765,7 @@ Response::ResponseCode AbstractServerSocketInterface::continuePasswordRequest(co
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
QString details =
|
QString details =
|
||||||
challenged ? "Request does not exist, challenge passed" : "Request does not exist, challenge not requested";
|
challenged ? "Request does not exist, challenge passed" : "Request does not exist, challenge not requested";
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_REQUEST", details, true);
|
"PASSWORD_RESET_REQUEST", details, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3783,7 +3785,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordReset(con
|
||||||
|
|
||||||
if (!sqlInterface->doesForgotPasswordExist(userName)) {
|
if (!sqlInterface->doesForgotPasswordExist(userName)) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET", "Request does not exist for user", false);
|
"PASSWORD_RESET", "Request does not exist for user", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3793,7 +3795,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordReset(con
|
||||||
if (!sqlInterface->validateTableColumnStringData("{prefix}_users", "token", userName,
|
if (!sqlInterface->validateTableColumnStringData("{prefix}_users", "token", userName,
|
||||||
nameFromStdString(cmd.token()))) {
|
nameFromStdString(cmd.token()))) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), userName.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), userName.simplified(),
|
||||||
"PASSWORD_RESET", "Failed token validation", false);
|
"PASSWORD_RESET", "Failed token validation", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3821,7 +3823,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordReset(con
|
||||||
|
|
||||||
if (sqlInterface->changeUserPassword(nameFromStdString(cmd.user_name()), password, passwordNeedsHash)) {
|
if (sqlInterface->changeUserPassword(nameFromStdString(cmd.user_name()), password, passwordNeedsHash)) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET", "", true);
|
"PASSWORD_RESET", "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3844,15 +3846,16 @@ AbstractServerSocketInterface::cmdForgotPasswordChallenge(const Command_ForgotPa
|
||||||
|
|
||||||
if (servatrice->recordForgotPasswordAttempt(this->getAddress())) {
|
if (servatrice->recordForgotPasswordAttempt(this->getAddress())) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_CHALLENGE", "Too many requests from this ip address", false);
|
"PASSWORD_RESET_CHALLENGE", "Too many requests from this ip address",
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
return Response::RespTooManyRequests;
|
return Response::RespTooManyRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!servatrice->getEnableForgotPasswordChallenge()) {
|
if (!servatrice->getEnableForgotPasswordChallenge()) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_CHALLENGE", "Feature not enabled", false);
|
"PASSWORD_RESET_CHALLENGE", "Feature not enabled", false);
|
||||||
}
|
}
|
||||||
return Response::RespFunctionNotAllowed;
|
return Response::RespFunctionNotAllowed;
|
||||||
|
|
@ -3860,7 +3863,7 @@ AbstractServerSocketInterface::cmdForgotPasswordChallenge(const Command_ForgotPa
|
||||||
|
|
||||||
if (!sqlInterface->userExists(userName)) {
|
if (!sqlInterface->userExists(userName)) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_CHALLENGE", "User does not exist", false);
|
"PASSWORD_RESET_CHALLENGE", "User does not exist", false);
|
||||||
}
|
}
|
||||||
return Response::RespFunctionNotAllowed;
|
return Response::RespFunctionNotAllowed;
|
||||||
|
|
@ -3869,7 +3872,7 @@ AbstractServerSocketInterface::cmdForgotPasswordChallenge(const Command_ForgotPa
|
||||||
const auto parsedEmailAddress = EmailParser::getParsedEmailAddress(nameFromStdString(cmd.email()));
|
const auto parsedEmailAddress = EmailParser::getParsedEmailAddress(nameFromStdString(cmd.email()));
|
||||||
if (!sqlInterface->validateTableColumnStringData("{prefix}_users", "email", userName, parsedEmailAddress)) {
|
if (!sqlInterface->validateTableColumnStringData("{prefix}_users", "email", userName, parsedEmailAddress)) {
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_CHALLENGE", "Failed to answer email challenge question",
|
"PASSWORD_RESET_CHALLENGE", "Failed to answer email challenge question",
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
@ -3877,7 +3880,7 @@ AbstractServerSocketInterface::cmdForgotPasswordChallenge(const Command_ForgotPa
|
||||||
}
|
}
|
||||||
|
|
||||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
databaseInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||||
"PASSWORD_RESET_CHALLENGE", "", true);
|
"PASSWORD_RESET_CHALLENGE", "", true);
|
||||||
}
|
}
|
||||||
return continuePasswordRequest(userName, clientId, rc, true);
|
return continuePasswordRequest(userName, clientId, rc, true);
|
||||||
|
|
@ -4259,7 +4262,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForceActivateUser(const
|
||||||
|
|
||||||
// Add audit log that Moderator activated account on behalf of user
|
// Add audit log that Moderator activated account on behalf of user
|
||||||
const auto &msg = QString("Attempt Force Activation by %1").arg(QString::fromStdString(cmd.moderator_name()));
|
const auto &msg = QString("Attempt Force Activation by %1").arg(QString::fromStdString(cmd.moderator_name()));
|
||||||
sqlInterface->addAuditRecord(QString::fromStdString(cmd.username_to_activate()), this->getAddress(), "UNKNOWN",
|
databaseInterface->addAuditRecord(QString::fromStdString(cmd.username_to_activate()), this->getAddress(), "UNKNOWN",
|
||||||
"ACTIVATE_ACCOUNT", msg, true);
|
"ACTIVATE_ACCOUNT", msg, true);
|
||||||
|
|
||||||
// Build up activation request
|
// Build up activation request
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue