Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions App/Server/clsRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ void clsRequestHandler::process(const QString& _api) {
static constexpr char MULTIPART_BOUNDARY_HEADER[] = "multipart/form-data; boundary=";

switch (ContentType.at(0)) {
case 'a':
{
case 'a': {
if (ContentType != APPLICATION_JSON_HEADER && ContentType != APPLICATION_FORM_HEADER)
throw exHTTPBadRequest(("unsupported Content-Type: " + ContentType).constData());

Expand Down Expand Up @@ -164,8 +163,8 @@ void clsRequestHandler::process(const QString& _api) {
}
break;
}
case 'm':
{

case 'm': {
if (this->MultipartFormDataHandler.isNull()) {
if (ContentType.startsWith(MULTIPART_BOUNDARY_HEADER) == false)
throw exHTTPBadRequest(("unsupported Content-Type: " + ContentType + " must be " + MULTIPART_BOUNDARY_HEADER).constData());
Expand All @@ -191,7 +190,7 @@ void clsRequestHandler::process(const QString& _api) {
}
default:
throw exHTTPBadRequest(("unsupported Content-Type: " + ContentType).constData());
}
} //switch

TargomanLogInfo(7, "request user defined values: ");
foreach (auto val, this->Request->userDefinedValues()) {
Expand Down Expand Up @@ -412,7 +411,9 @@ clsRequestHandler::stuResult clsRequestHandler::run(
JWT,
Headers.toVariant().toMap(),
Cookies.toVariant().toMap(),
RemoteIP
RemoteIP,
_queries,
this->Request->userDefinedValues()
);

QVariant Result = _apiObject->invoke(
Expand Down
31 changes: 30 additions & 1 deletion Interfaces/Server/APICallBoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class APICallBoomData : public QSharedData
RequestCookies(_other.RequestCookies),
JWT(_other.JWT),
IP(_other.IP),
RequestQueryParams(_other.RequestQueryParams),
RequestBodyParams(_other.RequestBodyParams),
ResponseHeaders(_other.ResponseHeaders),
AcceptLanguage(_other.AcceptLanguage)
{ ; }
Expand All @@ -64,6 +66,9 @@ class APICallBoomData : public QSharedData
QVariantMap RequestCookies;
TAPI::JWT_t JWT;
TAPI::RemoteIP_t IP;
QList<QPair<QString, QString>> RequestQueryParams;
QList<QPair<QString, QString>> RequestBodyParams;

QVariantMap ResponseHeaders;
QString AcceptLanguage;
};
Expand All @@ -77,14 +82,30 @@ void intfAPICallBoom::initialize(
const QJsonObject &_JWT,
const QVariantMap &_headers,
const QVariantMap &_cookies,
const QString &_ip
const QString &_ip,
const QStringList &_requestQueryParams,
const QList<QPair<QString, QString>> &_requestBodyParams
) {
this->Data->RequestAPIPath = _apiPath;
this->Data->RequestHeaders = _headers;
this->Data->RequestCookies = _cookies;
this->Data->JWT = _JWT;
this->Data->IP = _ip;

foreach (auto Item, _requestQueryParams) {
QStringList Parts = Item.split('=');
QString Name = Parts.at(0);

QString Value;
if (Parts.length() > 1) {
Parts.removeAt(0);
Value = QUrl::fromPercentEncoding(Parts.join('=').toUtf8());
}

this->Data->RequestQueryParams.append({ Name, Value });
}
this->Data->RequestBodyParams = _requestBodyParams;

this->Data->AcceptLanguage = "en";

if (this->Data->RequestHeaders.contains("accept-language")) {
Expand Down Expand Up @@ -113,6 +134,14 @@ QString intfAPICallBoom::getIP() {
return this->Data->IP;
}

QList<QPair<QString, QString>> intfAPICallBoom::getRequestQueryParams() {
return this->Data->RequestQueryParams;
}

QList<QPair<QString, QString>> intfAPICallBoom::getRequestBodyParams() {
return this->Data->RequestBodyParams;
}

//void intfAPICallBoom::setRequestAPIPath(const QString &_path) {
// this->Data->RequestAPIPath = _path;
//}
Expand Down
7 changes: 6 additions & 1 deletion Interfaces/Server/APICallBoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class intfAPICallBoom
const QJsonObject &_JWT,
const QVariantMap &_headers,
const QVariantMap &_cookies,
const QString &_ip
const QString &_ip,
const QStringList &_requestQueryParams,
const QList<QPair<QString, QString>> &_requestBodyParams
);

virtual bool needJWT() = 0;
Expand All @@ -84,6 +86,9 @@ class intfAPICallBoom

QString getIP();

QList<QPair<QString, QString>> getRequestQueryParams();
QList<QPair<QString, QString>> getRequestBodyParams();

// void setRequestAPIPath(const QString &_path);
QString requestAPIPath() const;
QString host(const QString &_default = "127.0.0.1") const;
Expand Down
4 changes: 2 additions & 2 deletions Modules/Account/functionalTest/testAccount.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ private slots:
{},
{
{ "email", UT_UserEmail },
{ "uuid", Code },
{ "code", Code },
{ "autoLogin", false },
});
// qDebug() << Result;
Expand All @@ -512,7 +512,7 @@ private slots:
{},
{
{ "email", UT_AdminUserEmail },
{ "uuid", Code },
{ "code", Code },
{ "autoLogin", false },
});
QVERIFY(Result.isValid());
Expand Down
4 changes: 2 additions & 2 deletions Modules/Account/moduleSrc/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ QVariantMap IMPL_REST_PUT(Account, signup, (
TAPI::EncodedJWT_t IMPL_REST_POST(Account, approveEmail, (
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM,
QString _email,
TAPI::MD5_t _uuid,
TAPI::MD5_t _code,
bool _autoLogin,
TAPI::CommaSeparatedStringList_t _services,
bool _rememberMe,
Expand All @@ -307,7 +307,7 @@ TAPI::EncodedJWT_t IMPL_REST_POST(Account, approveEmail, (
"spApproval_Accept", {
{ "iBy", "E" },
{ "iKey", _email },
{ "iCode", _uuid },
{ "iCode", _code },
{ "iLogin", _autoLogin ? 1 : 0 },
{ "iLoginIP", APICALLBOOM_PARAM.getIP() },
{ "iLoginInfo", _sessionInfo.object() },
Expand Down
2 changes: 1 addition & 1 deletion Modules/Account/moduleSrc/Account.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private slots:
(
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM,
QString _email,
TAPI::MD5_t _uuid,
TAPI::MD5_t _code,
bool _autoLogin = false,
TAPI::CommaSeparatedStringList_t _services = {},
bool _rememberMe = false,
Expand Down
24 changes: 22 additions & 2 deletions Modules/Account/moduleSrc/ORM/Payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,29 @@ QVariant IMPL_REST_GET_OR_POST(OnlinePayments, paymentCallback, (
gather (GET) and (POST) params into (ResponseParams)
*/

//curl -X POST 'http://localhost:10000/rest/v1/Account/OnlinePayments/paymentCallback?paymentKey=11&q1=qv1' -H 'content-type:application/json' -d '{"d1":"dv1"}'

QVariantMap ResponseParams;

return RESTClientHelper::callAPI(
QList<QPair<QString, QString>> RequestQueryParams = APICALLBOOM_PARAM.getRequestQueryParams();
foreach (auto Item, RequestQueryParams) {
if (Item.first == "paymentKey")
continue;

ResponseParams.insert(Item.first, Item.second);
}

QList<QPair<QString, QString>> RequestBodyParams = APICALLBOOM_PARAM.getRequestBodyParams();
foreach (auto Item, RequestBodyParams) {
ResponseParams.insert(Item.first, Item.second);
}

qDebug() << "ResponseParams:" << ResponseParams;

return true;


/*RESTClientHelper::callAPI(
RESTClientHelper::POST,
"Account/approveOnlinePayment",
{},
Expand All @@ -207,7 +227,7 @@ QVariant IMPL_REST_GET_OR_POST(OnlinePayments, paymentCallback, (
// { "domain", "dev.test" },
{ "pgResponse", ResponseParams },
}
);
);*/
}

/*****************************************************************\
Expand Down