45 QJsonObject
execute(
const QJsonObject& jsonObj, QMutex& m)
override
47 QMutexLocker locker(&m);
55 response.insert(
"Response", 1);
58 if (jsonObj.contains(
"Data"))
60 QJsonObject dataObj = jsonObj[
"Data"].toObject();
62 if (dataObj.contains(
"email"))
64 email = dataObj.value(
"email").toString();
67 if (dataObj.contains(
"password"))
69 password = dataObj.value(
"password").toString();
74 qCritical() <<
"Data not found";
85 int user_id = result.
first().value(
"id").toInt();
86 QJsonObject obj = result.
first();
94 if (result.
first().value(
"password").toString() != password)
99 data.insert(
"status",
int(
true));
100 data.insert(
"message",
"Login successful");
101 data.insert(
"first_name", obj.value(
"first_name").toString());
102 data.insert(
"role", obj.value(
"role").toString());
104 response.insert(
"Data", data);
108 QJsonDocument responseDoc(response);
109 QByteArray responseData = responseDoc.toJson();
112 qDebug().noquote() <<
"<-- Login::Response :\n" << responseDoc.toJson(QJsonDocument::Indented);
This file contains the declaration of the Request class, which is an abstract base class for handling...
Manages database connections and SQL operations.
Definition: db.h:80
DatabaseManager * table(const QString &value)
Sets the table for the query.
Definition: db.cpp:115
DatabaseManager * where(const QString &value, const QVariant &val=QVariant())
Adds a WHERE clause to the query.
Definition: db.cpp:121
DbResult exec()
Executes the built query.
Definition: db.cpp:266
DatabaseManager * select(const QString &value)
Selects columns for the query.
Definition: db.cpp:107
The DbResult class represents a result set returned from a database query.
Definition: dbresult.h:24
QJsonObject first() const
Retrieves the first item in the result set.
Definition: dbresult.cpp:25
bool isEmpty() const
Checks if the result set is empty.
Definition: dbresult.cpp:20
The LoginRequest class handles user login requests.
Definition: LoginRequest.h:20
LoginRequest()
Constructor for the LoginRequest class.
Definition: LoginRequest.h:30
QJsonObject execute(const QJsonObject &jsonObj, QMutex &m) override
Executes the login request.
Definition: LoginRequest.h:45
The Request class is an abstract base class for handling different types of requests.
Definition: Request.h:25
QJsonObject CreateErrorResponse(QJsonObject &response, QJsonObject &dataObj, QString message)
Creates a generic error JSON response.
Definition: Request.h:90
QJsonObject CreateDBConnectionError(QJsonObject &response, QJsonObject &dataObj)
Creates a JSON response indicating a database connection error.
Definition: Request.h:65
bool isDBConnectionValid(DB::DatabaseManager *dbManager)
Checks if the database connection is valid.
Definition: Request.h:36
Database management classes for handling database connections and operations.