Exemplo n.º 1
0
        public async void checkBloodcatCookies()
        {
            if (!String.IsNullOrEmpty(SettingManager.Get("bloodcatCookies")))
            {
                var cookies = await CookieStoreSerializer.DeserializeCookies(SettingManager.Get("bloodcatCookies"));

                Bloodcat.Cookies = cookies;
            }
        }
Exemplo n.º 2
0
        public static async Task TestCookies()
        {
            System.Net.CookieContainer cookies = null;
            try
            {
                cookies = await CookieStoreSerializer.DeserializeCookies(SettingManager.Get("officialOsuCookies"));
            }
            catch
            {
                // Corrupted cookie store, deleting corruption
                SettingManager.Set("officialOsuCookies", null);
                cookies = new System.Net.CookieContainer();
            }

            try
            {
                await Osu.CheckPassedLoginCookieElseUseNew(cookies, SettingManager.Get("officialOsuUsername"), SettingManager.Get("officialOsuPassword"));

                // store to parent & just persist them incase something new changed
                SettingManager.Set("officialOsuCookies", await CookieStoreSerializer.SerializeCookies(Osu.Cookies));
                return;
            }
            catch (Osu.InvalidPasswordException)
            {
                MessageBoxResult cookiePrompt = MessageBox.Show("There was an error logging in to your account. Maybe you have changed your password, etc... to update that click NO and visit settings.\nClick YES to retry connection, click NO to fall back to Bloodcat for this session.", "NexDirect - Error", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (cookiePrompt == MessageBoxResult.Yes)
                {
                    await TestCookies();

                    return;
                }
                SettingManager.Set("useOfficialOsu", false, true);
                SettingManager.Set("fallbackActualOsu", true, true);
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error connecting to osu! servers, falling back to Bloodcat for this session...\n\n" + ex.ToString());
                SettingManager.Set("useOfficialOsu", false, true);
                SettingManager.Set("fallbackActualOsu", true, true);
                return;
            }
        }