コード例 #1
0
        public Process Login(string username, string password, string otp, bool useCache = false)
        {
            string uid;
            var    needsUpdate    = false;
            var    expansionLevel = Settings.GetExpansionLevel();

            OauthLoginResult loginResult;

            if (!useCache || !Cache.HasValidCache(username))
            {
                loginResult = Task.Run(() => OauthLogin(username, password, otp)).Result;

                if (!loginResult.Playable)
                {
                    MessageBox.Show("This Square Enix account cannot play FINAL FANTASY XIV.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                if (!loginResult.TermsAccepted)
                {
                    MessageBox.Show("Please accept the FINAL FANTASY XIV Terms of Use in the official launcher.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                // Clamp the expansion level to what the account is allowed to access
                expansionLevel     = Math.Min(Math.Max(loginResult.MaxExpansion, 0), expansionLevel);
                (uid, needsUpdate) = Task.Run(() => RegisterSession(loginResult)).Result;

                if (useCache)
                {
                    Task.Run(() => Cache.AddCachedUid(username, uid, loginResult.Region)).Wait();
                }
            }
            else
            {
                var(cachedUid, region) = Task.Run(() => Cache.GetCachedUid(username)).Result;
                uid = cachedUid;

                loginResult = new OauthLoginResult
                {
                    Playable      = true,
                    Region        = region,
                    TermsAccepted = true
                };
            }

            if (needsUpdate)
            {
                MessageBox.Show(
                    "Your game is out of date. Please start the official launcher and update it before trying to log in.",
                    "Out of date", MessageBoxButton.OK, MessageBoxImage.Error);

                return(null);
            }

            return(LaunchGame(uid, loginResult.Region, expansionLevel));
        }
コード例 #2
0
        public Process Login(string userName, string password, string otp, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments, bool useCache)
        {
            string uid;
            var    needsUpdate = false;

            OauthLoginResult loginResult;

            Log.Information($"XivGame::Login(steamIntegration:{isSteamIntegrationEnabled}, steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments}, cache:{useCache})");

            if (!useCache || !Cache.HasValidCache(userName))
            {
                Log.Information("Cache is invalid or disabled, logging in normally.");

                try
                {
                    loginResult = OauthLogin(userName, password, otp, isSteamServiceAccount);

                    Log.Information($"OAuth login successful - playable:{loginResult.Playable} terms:{loginResult.TermsAccepted} region:{loginResult.Region} expack:{loginResult.MaxExpansion}");
                }
                catch (Exception ex)
                {
                    Log.Information(ex, "OAuth login failed.");
                    MessageBox.Show(
                        "Could not login into your Square Enix account.\nThis could be caused by bad credentials or OTPs.\n\nPlease also check your email inbox for any messages from Square Enix - they might want you to reset your password due to \"suspicious activity\".\nThis is NOT caused by a security issue in XIVLauncher, it is merely a safety measure by Square Enix to prevent logins from new locations, in case your account is getting stolen.\nXIVLauncher and the official launcher will work fine again after resetting your password.",
                        "Login issue", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                if (!loginResult.Playable)
                {
                    MessageBox.Show("This Square Enix account cannot play FINAL FANTASY XIV.\n\nIf you bought FINAL FANTASY XIV on Steam, make sure to check the \"Use Steam service account\" checkbox while logging in.\nIf Auto-Login is enabled, hold shift while starting to access settings.", "Error",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                if (!loginResult.TermsAccepted)
                {
                    MessageBox.Show("Please accept the FINAL FANTASY XIV Terms of Use in the official launcher.",
                                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                (uid, needsUpdate) = Task.Run(() => RegisterSession(loginResult)).Result;

                if (useCache)
                {
                    Task.Run(() => Cache.AddCachedUid(userName, uid, loginResult.Region, loginResult.MaxExpansion))
                    .Wait();
                }
            }
            else
            {
                Log.Information("Cached UID found, using instead.");
                var(cachedUid, region, expansionLevel) = Task.Run(() => Cache.GetCachedUid(userName)).Result;
                uid = cachedUid;

                loginResult = new OauthLoginResult
                {
                    Playable      = true,
                    Region        = region,
                    TermsAccepted = true,
                    MaxExpansion  = expansionLevel
                };
            }

            if (needsUpdate)
            {
                MessageBox.Show(
                    "Your game is out of date. Please start the official launcher and update it before trying to log in.",
                    "Out of date", MessageBoxButton.OK, MessageBoxImage.Error);

                return(null);
            }

            return(LaunchGame(uid, loginResult.Region, loginResult.MaxExpansion, isSteamIntegrationEnabled, isSteamServiceAccount, additionalArguments));
        }
コード例 #3
0
        public LoginResult Login(string userName, string password, string otp, bool isSteamServiceAccount, bool useCache, DirectoryInfo gamePath)
        {
            string uid;

            PatchListEntry[] pendingPatches = null;

            OauthLoginResult oauthLoginResult;

            LoginState loginState;

            Log.Information($"XivGame::Login(steamServiceAccount:{isSteamServiceAccount}, cache:{useCache})");

            if (!useCache || !Cache.HasValidCache(userName))
            {
                Log.Information("Cache is invalid or disabled, logging in normally.");

                try
                {
                    oauthLoginResult = OauthLogin(userName, password, otp, isSteamServiceAccount, 3);

                    Log.Information($"OAuth login successful - playable:{oauthLoginResult.Playable} terms:{oauthLoginResult.TermsAccepted} region:{oauthLoginResult.Region} expack:{oauthLoginResult.MaxExpansion}");
                }
                catch (Exception ex)
                {
                    Log.Information(ex, "OAuth login failed.");
                    MessageBox.Show(
                        "Could not login into your Square Enix account.\nThis could be caused by bad credentials or OTPs.\n\nPlease also check your email inbox for any messages from Square Enix - they might want you to reset your password due to \"suspicious activity\".\nThis is NOT caused by a security issue in XIVLauncher, it is merely a safety measure by Square Enix to prevent logins from new locations, in case your account is getting stolen.\nXIVLauncher and the official launcher will work fine again after resetting your password.",
                        "Login issue", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                if (!oauthLoginResult.Playable)
                {
                    MessageBox.Show("This Square Enix account cannot play FINAL FANTASY XIV.\n\nIf you bought FINAL FANTASY XIV on Steam, make sure to check the \"Use Steam service account\" checkbox while logging in.\nIf Auto-Login is enabled, hold shift while starting to access settings.", "Error",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                if (!oauthLoginResult.TermsAccepted)
                {
                    MessageBox.Show("Please accept the FINAL FANTASY XIV Terms of Use in the official launcher.",
                                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                (uid, loginState, pendingPatches) = Task.Run(() => RegisterSession(oauthLoginResult, gamePath)).Result;

                if (useCache)
                {
                    Task.Run(() => Cache.AddCachedUid(userName, uid, oauthLoginResult.Region, oauthLoginResult.MaxExpansion))
                    .Wait();
                }
            }
            else
            {
                Log.Information("Cached UID found, using instead.");
                var(cachedUid, region, expansionLevel) = Task.Run(() => Cache.GetCachedUid(userName)).Result;
                uid        = cachedUid;
                loginState = LoginState.Ok;

                oauthLoginResult = new OauthLoginResult
                {
                    Playable      = true,
                    Region        = region,
                    TermsAccepted = true,
                    MaxExpansion  = expansionLevel
                };
            }

            return(new LoginResult
            {
                PendingPatches = pendingPatches,
                OauthLogin = oauthLoginResult,
                State = loginState,
                UniqueId = uid
            });
        }
コード例 #4
0
        public Process Login(string username, string password, string otp, bool useCache = false)
        {
            string uid;
            var    needsUpdate = false;

            OauthLoginResult loginResult = null;

            if (!useCache || !Cache.HasValidCache(username))
            {
                Serilog.Log.Information("Cache is invalid or disabled, logging in normally.");

                try
                {
                    loginResult = OauthLogin(username, password, otp);
                }
                catch (Exception ex)
                {
                    Serilog.Log.Error("OAuth login failed.", ex);
                    MessageBox.Show(
                        "Could not login into your Square Enix account.\nThis could be caused by bad credentials or OTPs.\n\nPlease also check your email inbox for any messages from Square Enix - they might want you to reset your password due to \"suspicious activity\".\nThis is NOT caused by a security issue in XIVLauncher, it is merely a safety measure by Square Enix to prevent logins from new locations, in case your account is getting stolen.\nXIVLauncher and the official launcher will work fine again after resetting your password.", "Login issue", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                if (!loginResult.Playable)
                {
                    MessageBox.Show("This Square Enix account cannot play FINAL FANTASY XIV.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                if (!loginResult.TermsAccepted)
                {
                    MessageBox.Show("Please accept the FINAL FANTASY XIV Terms of Use in the official launcher.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                (uid, needsUpdate) = Task.Run(() => RegisterSession(loginResult)).Result;

                if (useCache)
                {
                    Task.Run(() => Cache.AddCachedUid(username, uid, loginResult.Region)).Wait();
                }
            }
            else
            {
                Serilog.Log.Information("Cached UID found, using instead.");
                var(cachedUid, region, expansionLevel) = Task.Run(() => Cache.GetCachedUid(username)).Result;
                uid = cachedUid;

                loginResult = new OauthLoginResult
                {
                    Playable      = true,
                    Region        = region,
                    TermsAccepted = true,
                    MaxExpansion  = expansionLevel
                };
            }

            if (needsUpdate)
            {
                MessageBox.Show(
                    "Your game is out of date. Please start the official launcher and update it before trying to log in.",
                    "Out of date", MessageBoxButton.OK, MessageBoxImage.Error);

                return(null);
            }

            return(LaunchGame(uid, loginResult.Region, loginResult.MaxExpansion));
        }
コード例 #5
0
ファイル: Launcher.cs プロジェクト: perize/FFXIVQuickLauncher
        public LoginResult Login(string userName, string password, string otp, bool isSteamServiceAccount, bool useCache, DirectoryInfo gamePath)
        {
            string uid;

            PatchListEntry[] pendingPatches = null;

            OauthLoginResult oauthLoginResult;

            LoginState loginState;

            Log.Information($"XivGame::Login(steamServiceAccount:{isSteamServiceAccount}, cache:{useCache})");

            if (!useCache || !Cache.HasValidCache(userName))
            {
                Log.Information("Cache is invalid or disabled, logging in normally.");

                try
                {
                    oauthLoginResult = OauthLogin(userName, password, otp, isSteamServiceAccount, 3);

                    Log.Information($"OAuth login successful - playable:{oauthLoginResult.Playable} terms:{oauthLoginResult.TermsAccepted} region:{oauthLoginResult.Region} expack:{oauthLoginResult.MaxExpansion}");
                }
                catch (Exception ex)
                {
                    Log.Information(ex, "OAuth login failed.");

                    return(new LoginResult
                    {
                        State = LoginState.NoOAuth
                    });
                }

                if (!oauthLoginResult.Playable)
                {
                    MessageBox.Show("This Square Enix account cannot play FINAL FANTASY XIV.\n\nIf you bought FINAL FANTASY XIV on Steam, make sure to check the \"Use Steam service account\" checkbox while logging in.\nIf Auto-Login is enabled, hold shift while starting to access settings.", "Error",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                if (!oauthLoginResult.TermsAccepted)
                {
                    MessageBox.Show("Please accept the FINAL FANTASY XIV Terms of Use in the official launcher.",
                                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                (uid, loginState, pendingPatches) = Task.Run(() => RegisterSession(oauthLoginResult, gamePath)).Result;

                if (useCache)
                {
                    Task.Run(() => Cache.AddCachedUid(userName, uid, oauthLoginResult.Region, oauthLoginResult.MaxExpansion))
                    .Wait();
                }
            }
            else
            {
                Log.Information("Cached UID found, using instead.");
                var(cachedUid, region, expansionLevel) = Task.Run(() => Cache.GetCachedUid(userName)).Result;
                uid        = cachedUid;
                loginState = LoginState.Ok;

                oauthLoginResult = new OauthLoginResult
                {
                    Playable      = true,
                    Region        = region,
                    TermsAccepted = true,
                    MaxExpansion  = expansionLevel
                };
            }

            return(new LoginResult
            {
                PendingPatches = pendingPatches,
                OauthLogin = oauthLoginResult,
                State = loginState,
                UniqueId = uid
            });
        }