40 lines
851 B
C++
40 lines
851 B
C++
|
|
#ifndef AUTH_DIALOG_H
|
||
|
|
#define AUTH_DIALOG_H
|
||
|
|
|
||
|
|
#include "ui_auth_dialog.h"
|
||
|
|
#include <QDialog>
|
||
|
|
#include <QSqlDatabase>
|
||
|
|
|
||
|
|
// Forward declaration
|
||
|
|
class RolesRepositoryInterface;
|
||
|
|
class UserDTO;
|
||
|
|
class UsersRepositoryInterface;
|
||
|
|
|
||
|
|
class AuthDialog : public QDialog, private Ui::AuthDialog {
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
private:
|
||
|
|
RolesRepositoryInterface *rolesRepository_;
|
||
|
|
UsersRepositoryInterface *usersRepository_;
|
||
|
|
|
||
|
|
public:
|
||
|
|
explicit AuthDialog(QWidget *parent = nullptr);
|
||
|
|
|
||
|
|
signals:
|
||
|
|
void loginSuccessful(qint32 userId, qint32 accessLevel);
|
||
|
|
void loginFailed();
|
||
|
|
|
||
|
|
private slots:
|
||
|
|
void onCancelClicked();
|
||
|
|
void onLoginClicked();
|
||
|
|
|
||
|
|
private:
|
||
|
|
bool initializeRepositories();
|
||
|
|
void setupConnections();
|
||
|
|
|
||
|
|
QString hashPassword(const QString &password, const QString &salt);
|
||
|
|
bool verifyPassword(const QString &password, const UserDTO &userDTO);
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif // AUTH_DIALOG_H
|