mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Serve account self-service updates through the database interface (#7848)
cmdAccountEdit assembled a dynamic UPDATE for the real name, email and country columns in the socket handler, and cmdAccountImage wrote the avatar blob there too. Add AccountUpdateRecord, updateUserAccount and setUserAvatar to Server_DatabaseInterface with fail-closed defaults, implement them with the previous query text and bind values, and keep the password gate, the email permission check, the empty-edit early return and the in-memory userInfo updates in the handler.
This commit is contained in:
parent
8c8dd0c072
commit
f7c6e81347
4 changed files with 75 additions and 30 deletions
|
|
@ -774,6 +774,24 @@ public:
|
|||
virtual void setForcePasswordChange(const QString & /* user */, bool /* force */)
|
||||
{
|
||||
}
|
||||
/** @brief The account fields a self-service edit may change; unset fields are left alone. */
|
||||
struct AccountUpdateRecord
|
||||
{
|
||||
bool hasRealName = false;
|
||||
QString realName;
|
||||
bool hasEmail = false;
|
||||
QString email;
|
||||
bool hasCountry = false;
|
||||
QString country;
|
||||
};
|
||||
virtual bool updateUserAccount(const QString & /* userName */, const AccountUpdateRecord & /* update */)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool setUserAvatar(int /* userId */, const QByteArray & /* image */)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/** @brief Outcome of reading or writing one account field. */
|
||||
enum class UserFieldResult
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue