コード例 #1
0
ファイル: LoginWindow.xaml.cs プロジェクト: Frimia/SynapseX-1
        private bool Login(string Username, string Password)
        {
            var Result = WebInterface.Login(Username, Password);

            switch (Result.Result)
            {
            case WebInterface.LoginResult.OK:
            {
                DataInterface.Delete("login");
                DataInterface.Save("token", Result.Token);
                return(true);
            }

            case WebInterface.LoginResult.INVALID_USER_PASS:
            {
                Dispatcher.Invoke(() =>
                    {
                        MessageBox.Show(
                            "Invalid username/email or password.",
                            "Synapse X", MessageBoxButton.OK, MessageBoxImage.Error);
                        LoginButton.Content = "Login";
                        LoggingIn           = false;
                    });
                return(false);
            }

            case WebInterface.LoginResult.NOT_MIGRATED:
            {
                Migrate(Username, Password);
                return(false);
            }

            case WebInterface.LoginResult.INVALID_REQUEST:
            case WebInterface.LoginResult.UNKNOWN:
            {
                Dispatcher.Invoke(() =>
                    {
                        Topmost = false;
                        MessageBox.Show(
                            "Failed to login to Synapse account. Please contact 3dsboy08 on Discord.",
                            "Synapse X", MessageBoxButton.OK, MessageBoxImage.Error);
                    });
                Environment.Exit(0);
                return(false);
            }
            }

            return(false);
        }