* protocol changes * server changes * client changes for password reset and registration * add hashed password to change password in client * always use hashed password to log in * add warning to client when using plain text password * require real password for changing email on server this is backwards compatible as users logged in with a real password on older clients will not need this, only users logged in with a hashed password * implement password dialog when changing email * require min password length * use qstringlist to build query instead * use clear instead of = "" * add max to password dialog * use proper const ness in abstractclient * reject too long passwords instead of trimming
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#ifndef USERINFOBOX_H
|
|
#define USERINFOBOX_H
|
|
|
|
#include <QDateTime>
|
|
#include <QLabel>
|
|
#include <QPushButton>
|
|
#include <QWidget>
|
|
|
|
class ServerInfo_User;
|
|
class AbstractClient;
|
|
class Response;
|
|
|
|
class UserInfoBox : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
private:
|
|
AbstractClient *client;
|
|
bool editable;
|
|
QLabel avatarLabel, nameLabel, realNameLabel1, realNameLabel2, countryLabel1, countryLabel2, countryLabel3,
|
|
userLevelLabel1, userLevelLabel2, userLevelLabel3, accountAgeLabel1, accountAgeLabel2;
|
|
QPushButton editButton, passwordButton, avatarButton;
|
|
QPixmap avatarPixmap;
|
|
|
|
static QString getAgeString(int ageSeconds);
|
|
|
|
public:
|
|
UserInfoBox(AbstractClient *_client, bool editable, QWidget *parent = nullptr, Qt::WindowFlags flags = {});
|
|
void retranslateUi();
|
|
|
|
inline static QPair<int, int> getDaysAndYearsBetween(const QDate &then, const QDate &now)
|
|
{
|
|
int years = now.addDays(1 - then.dayOfYear()).year() - then.year(); // there is no yearsTo
|
|
int days = then.addYears(years).daysTo(now);
|
|
return {days, years};
|
|
}
|
|
private slots:
|
|
void processResponse(const Response &r);
|
|
void processEditResponse(const Response &r);
|
|
void processPasswordResponse(const Response &r);
|
|
void processAvatarResponse(const Response &r);
|
|
|
|
void actEdit();
|
|
void actEditInternal(const Response &r);
|
|
void actPassword();
|
|
void actAvatar();
|
|
public slots:
|
|
void updateInfo(const ServerInfo_User &user);
|
|
void updateInfo(const QString &userName);
|
|
|
|
private:
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
void changePassword(const QString &oldPassword, const QString &newPassword);
|
|
};
|
|
|
|
#endif
|