Skip to content

Fix: invalidver opt-in auto-open#56

Open
Wimberton wants to merge 4 commits intoKeyAuth:mainfrom
Wimberton:fix/invalidver-auto-open
Open

Fix: invalidver opt-in auto-open#56
Wimberton wants to merge 4 commits intoKeyAuth:mainfrom
Wimberton:fix/invalidver-auto-open

Conversation

@Wimberton
Copy link

@Wimberton Wimberton commented Mar 9, 2026

When using invalidver handling in my loaders, the library always opened the download URL and exited before my code could run. That prevented showing a custom error (e.g. console message + countdown) or using app_data.downloadLink in my own UI. This change makes the old auto-open-and-exit behavior opt-in via auto_open_download_url, and ensures response.message is set so callers can detect and display the error. Example of the flow I wanted to support:

if (KeyAuthApp.response.message == "invalidver") {
    std::cout << "Your loader is outdated!" << std::endl;
    if (!KeyAuthApp.app_data.downloadLink.empty()) {
        std::cout << "Please visit our website to download the latest version:" << std::endl;
        std::cout << KeyAuthApp.app_data.downloadLink << std::endl;
    } else {
        std::cout << "Please download the latest version." << std::endl; // e.g. when white labeling loaders
    }
    // e.g. countdown then return 1
}

The default is auto_open_download_url= true, so existing code keeps the original behavior (open URL and exit). No changes required for current users. I consider that behavior broken for loaders that want to handle the error themselves; set auto_open_download_url = false before init() to get the new behavior.

Summary

  • Opt-in caller handling: A new auto_open_download_url flag (default true) controls invalidver behavior. When true, behavior is unchanged: open download URL if set, then exit. When false, the library stores the download link and returns so the caller can handle the error.
  • Descriptive error: When the server returns invalidver, response.message is now set so callers can show a clear message:
    • If the dashboard download link is blank: a full diagnostic string (version mismatch + how to fix).
    • If the download link is present: "invalidver" so the caller can detect and display it.

Behavior

auto_open_download_url Result
true (default) Same as before: open URL if non-empty, then exit(0). No change for existing users.
false No URL open, no exit; app_data.downloadLink and response.message are set for the caller.

Files

  • auth.hpp: added bool auto_open_download_url = true;
  • auth.cpp: invalidver block updated to set response.message and to open/exit only when auto_open_download_url is true

…l flag

Replace the unconditional URL open and exit on invalidver with a
configurable autoOpenDownloadUrl flag (default false). When disabled,
the library stores the download link and returns control to the caller,
allowing custom error handling. Set true before init() to restore the
old auto-open-and-exit behavior.
Populate response.message with a detailed diagnostic string when
invalidver is returned and the download link is blank, allowing the
caller to display the error in their own UI. When the download link
is present, response.message is set to "invalidver" for easy detection.
…flag, which defaults to true for backward compatibility.
@Wimberton Wimberton marked this pull request as draft March 9, 2026 19:36
@Wimberton Wimberton marked this pull request as ready for review March 9, 2026 19:39
@Wimberton
Copy link
Author

Wimberton commented Mar 9, 2026

Silly me.
I've updated the variable to match the project snake-case.

duh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants