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
25 changes: 25 additions & 0 deletions Modules/Account/functionalTest/testAccount.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,31 @@ private slots:
}
}

void apitoken_revoke_again() {
this->OldTokenJWT = this->TokenJWT;

QT_TRY {
QVariant Result = this->callUserAPI(
RESTClientHelper::enuHTTPMethod::POST,
"Account/APITokens/revoke",
{},
{
{ "token", this->TokenJWT },
{ "pass", "5d12d36cd5f66fe3e72f7b03cbb75333" },
{ "salt", "1234" },
});

QVERIFY(Result.isValid());

this->TokenJWT = Result.toMap().value("token").toString();

QVERIFY(this->TokenJWT.isEmpty() == false);

} QT_CATCH (const std::exception &exp) {
QTest::qFail(exp.what(), __FILE__, __LINE__);
}
}

void apitoken_api_ping_after_revoke_old() {
QT_TRY {
QVariant Result = this->callAPI(
Expand Down
9 changes: 7 additions & 2 deletions Modules/Account/moduleSrc/ORM/APITokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,17 @@ Targoman::API::AccountModule::stuRequestTokenResult IMPL_REST_POST(APITokens, re
QDateTime ExpireDateTime = QDateTime::fromSecsSinceEpoch(TokenJWTPayload["exp"].toDouble());

//----------------------------------------

// TargomanDebug(5) << "before" << TokenJWTPayload;

int RevokeCounter = 0;
if (TokenJWTPayload.contains("rvk"))
RevokeCounter = TokenJWTPayload["rvk"].toInt();
if (TokenJWTPayload.contains("rvkcnt"))
RevokeCounter = TokenJWTPayload["rvkcnt"].toInt();
++RevokeCounter;
TokenJWTPayload["rvkcnt"] = RevokeCounter;

// TargomanDebug(5) << "after" << TokenJWTPayload;

//----------------------------------------
QString NewToken = QJWT::encryptAndSigned(TokenJWTPayload);

Expand Down