Skip to content

Commit 0173044

Browse files
committed
Check if the user has the auth bot account blocked upon auth failure, and return a special message
1 parent 49f5b9d commit 0173044

6 files changed

Lines changed: 54 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set(CMAKE_CXX_STANDARD 20)
33
set(CMAKE_CXX_STANDARD_REQUIRED ON)
44
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
55

6-
project(argon VERSION 1.4.7)
6+
project(argon VERSION 1.4.8)
77

88
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
99
src/*.cpp

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Benefits compared to some of the other auth APIs (Globed, DashAuth, GDAuth):
1818
First, add Argon to the `CMakeLists.txt` of your mod:
1919

2020
```cmake
21-
CPMAddPackage("gh:GlobedGD/argon@1.4.7")
21+
CPMAddPackage("gh:GlobedGD/argon@1.4.8")
2222
target_link_libraries(${PROJECT_NAME} argon)
2323
```
2424

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.4.8
2+
3+
* Check if the user has the auth bot account blocked upon auth failure, and return a special message
4+
15
# 1.4.7
26

37
* Make `getGameAccountData` print a warning instead of crashing when called off main thread

src/Main.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,18 @@ static Future<Result<>> submitSolution(const AccountData& account, std::string_v
140140
co_return co_await web::submitGDMessage(account, id, text);
141141
}
142142

143-
static Future<std::string> troubleshootFailureCause(const AccountData& account) {
143+
static Future<std::string> troubleshootFailureCause(const AccountData& account, int targetId) {
144144
auto result = co_await web::checkGDMessageLimit(account);
145145
if (result.isErr()) {
146146
co_return std::move(result).unwrapErr();
147147
}
148-
co_return "Stage 2 failed due to unknown error, auth and message limit are OK";
148+
149+
result = co_await web::checkGDUserNotBlocked(account, targetId);
150+
if (result.isErr()) {
151+
co_return std::move(result).unwrapErr();
152+
}
153+
154+
co_return "Stage 2 failed due to unknown error, all sanity checks succeeded";
149155
}
150156

151157
AuthFuture startAuth(AuthOptions options) {
@@ -179,7 +185,7 @@ AuthFuture startAuth(AuthOptions options) {
179185
auto solution = solveChallenge(s1data.challenge);
180186
auto s2res = co_await submitSolution(options.account, solution, s1data.id);
181187
if (!s2res) {
182-
co_return Err(co_await troubleshootFailureCause(options.account));
188+
co_return Err(co_await troubleshootFailureCause(options.account, s1data.id));
183189
}
184190

185191
progress(AuthProgress::VerifyingChallenge);

src/Web.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,42 @@ Future<Result<>> checkGDMessageLimit(const AccountData& account) {
279279
co_return Ok();
280280
}
281281

282+
Future<Result<>> checkGDUserNotBlocked(const AccountData& account, int targetUser) {
283+
auto payload = fmt::format(
284+
"accountID={}&gjp2={}&gameVersion=22&binaryVersion=45"
285+
"&secret=Wmfd2893gb7&type=1&dvs=3",
286+
account.accountId, account.gjp2
287+
);
288+
289+
auto response = co_await baseGDRequest()
290+
.bodyString(payload)
291+
.post(fmt::format("{}/getGJUserList20.php", account.serverUrl));
292+
293+
ARC_CO_UNWRAP_INTO(response, wrapResponse("fetch GD blocklist", std::move(response)));
294+
auto str = response.string().unwrapOrDefault();
295+
if (str.empty()) {
296+
co_return Err(wrapError(response, "fetch GD messages"));
297+
}
298+
299+
if (str == "-1") {
300+
co_return Err("Invalid account credentials, please try to Refresh Login in account settings");
301+
} else if (str == "-2") {
302+
co_return Ok();
303+
} else if (str.starts_with("-")) {
304+
co_return Err("Unexpected server response while fetching blocklist: {}", str);
305+
}
306+
307+
std::string targetStr = fmt::to_string(targetUser);
308+
309+
for (auto user : asp::iter::split(str, "|")) {
310+
for (auto [k, v] : asp::iter::split(user, ':').arrayChunks<2>()) {
311+
if (k == "16" && v == targetStr) {
312+
co_return Err("You have blocked the authentication bot account, please unblock it and try again");
313+
}
314+
}
315+
}
316+
317+
co_return Ok();
318+
}
319+
282320
}

src/Web.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ arc::Future<geode::Result<>> submitGDMessage(const AccountData& account, int tar
2626
arc::Future<geode::Result<>> deleteGDMessage(const AccountData& account, int id);
2727
arc::Future<geode::Result<>> submitGDComment(const AccountData& account, int target, std::string_view message);
2828
arc::Future<geode::Result<>> checkGDMessageLimit(const AccountData& account);
29+
arc::Future<geode::Result<>> checkGDUserNotBlocked(const AccountData& account, int targetUser);
2930

3031
}

0 commit comments

Comments
 (0)