1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-06-09 15:17:44 +00:00

Improve login process

More progress on support Steam service accounts, make it clear whether
or not you have a expired subscription/terms not accepted. Also add
"Free Trial" as a license type.
This commit is contained in:
Joshua Goins 2022-03-16 14:33:04 -04:00
parent c460f2d956
commit 8408a2b154
4 changed files with 55 additions and 12 deletions

View file

@ -17,7 +17,8 @@ class Watchdog;
enum class GameLicense {
WindowsStandalone,
WindowsSteam,
macOS
macOS,
FreeTrial
};
struct ProfileSettings {

View file

@ -23,7 +23,7 @@ signals:
private:
QString getBootHash(const LoginInformation& info);
QString stored, SID;
QString stored, SID, username;
LoginAuth auth;
LauncherCore& window;

View file

@ -105,7 +105,13 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
gameArgs.push_back({"IsSteam", "1"});
env.insert("IS_FFXIV_LAUNCH_FROM_STEAM", QString::number(1));
}
env.insert("DALAMUD_RUNTIME", "Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime");
if(profile.dalamud.enabled) {
// TODO: this depends on the default wine Z: path existing, which may not
// always the case.
env.insert("DALAMUD_RUNTIME",
"Z:" + dataDir.replace('/', '\\') + "\\DalamudRuntime");
}
gameProcess->setProcessEnvironment(env);

View file

@ -31,12 +31,22 @@ QString getFileHash(QString file) {
void SquareLauncher::getStored(const LoginInformation& info) {
QUrlQuery query;
// en is always used to the top url
query.addQueryItem("lng", "en");
// for some reason, we always use region 3. the actual region is acquired later
query.addQueryItem("rgn", "3");
query.addQueryItem("isft", "0");
query.addQueryItem("isft", info.settings->license == GameLicense::FreeTrial ? "1" : "0");
query.addQueryItem("cssmode", "1");
query.addQueryItem("isnew", "1");
query.addQueryItem("issteam", info.settings->license == GameLicense::WindowsSteam ? "1" : "0");
query.addQueryItem("launchver", "3");
if(info.settings->license == GameLicense::WindowsSteam) {
query.addQueryItem("issteam", "1");
// TODO: get steam ticket information from steam api
query.addQueryItem("session_ticket", "1");
query.addQueryItem("ticket_size", "1");
}
QUrl url("https://ffxiv-login.square-enix.com/oauth/ffxivarr/login/top");
url.setQuery(query);
@ -49,6 +59,21 @@ void SquareLauncher::getStored(const LoginInformation& info) {
connect(reply, &QNetworkReply::finished, [=] {
auto str = QString(reply->readAll());
// fetches Steam username
if(info.settings->license == GameLicense::WindowsSteam) {
QRegularExpression re(R"lit(<input name=""sqexid"" type=""hidden"" value=""(?<sqexid>.*)""\/>)lit");
QRegularExpressionMatch match = re.match(str);
if(match.hasMatch()) {
username = match.captured(1);
} else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Could not get Steam username, have you attached your account?");
messageBox->show();
}
} else {
username = info.username;
}
QRegularExpression re(R"lit(\t<\s*input .* name="_STORED_" value="(?<stored>.*)">)lit");
QRegularExpressionMatch match = re.match(str);
if (match.hasMatch()) {
@ -86,18 +111,29 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) {
const bool terms = parts[3] == "1";
const bool playable = parts[9] == "1";
if(!terms || !playable) {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Your game is unplayable. You may need to accept the terms from the official launcher.");
if(!playable) {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Your game is unplayable. Please check that you have the right license selected, and a subscription to play.");
window.addUpdateButtons(*info.settings, *messageBox);
messageBox->show();
} else {
SID = parts[1];
auth.region = parts[5].toInt();
auth.maxExpansion = parts[13].toInt();
registerSession(info);
return;
}
if(!terms) {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Your game is unplayable. You need to accept the terms of service from the official launcher.");
window.addUpdateButtons(*info.settings, *messageBox);
messageBox->show();
return;
}
SID = parts[1];
auth.region = parts[5].toInt();
auth.maxExpansion = parts[13].toInt();
registerSession(info);
} else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Invalid username/password.");
messageBox->show();