[Server] Serve account moderation through the database interface (#7849)

The moderator account commands still reached Servatrice_DatabaseInterface through
its concrete class: cmdResetUserPassword ran the privilege lookup inline and
called the concrete-only changeUserPasswordWithLegacyBackup, while the avatar,
banner and blacklisted-banner commands called concrete-only helpers. Promote
those four methods to Server_DatabaseInterface, move RemoveUserBannerResult into
the interface, and add getUserAdminFlags for the reset privilege lookup. The
escalation guard, audit records, had_banner response field and every response
code stay in the handler.
This commit is contained in:
BruebachL 2026-11-10 12:16:29 +01:00 • committed by GitHub
parent f7c6e81347
commit 2608228bdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 67 additions and 29 deletions

View file

@ -771,6 +771,12 @@ public:
{
return false;
}
virtual bool changeUserPasswordWithLegacyBackup(const QString & /* user */,
const QString & /* passwordVerifier */,
const QString & /* legacyCredential */)
{
return false;
}
virtual void setForcePasswordChange(const QString & /* user */, bool /* force */)
{
}
@ -792,6 +798,31 @@ public:
{
return false;
}
/** @brief Outcome of removing a user's banner, so a missing user stays distinguishable. */
enum class RemoveUserBannerResult
{
Removed,
NothingToRemove,
NoSuchUser,
DatabaseError
};
virtual RemoveUserBannerResult removeUserBanner(const QString & /* userName */)
{
return RemoveUserBannerResult::DatabaseError;
}
virtual bool removeUserAvatar(const QString & /* userName */)
{
return false;
}
virtual int clearBlacklistedBanners()
{
return -1;
}
/** @brief The raw admin bitmask of a user; false when the query failed or the user is missing. */
virtual bool getUserAdminFlags(const QString & /* userName */, int & /* adminFlags */)
{
return false;
}
/** @brief Outcome of reading or writing one account field. */
enum class UserFieldResult
{