Ejemplo n.º 1
0
        public void Login(string email, string password)
        {
            var statusCode = 200;
            var json       = string.Empty;

            LoginCallback?.Invoke(statusCode, json);
        }
Ejemplo n.º 2
0
        private void OnLoginCallback(RequestException request, ResponseHelper response)
        {
            var statusCode = response.StatusCode;
            var json       = response.Text;

            LoginCallback?.Invoke(statusCode, json);
        }
Ejemplo n.º 3
0
 private void btLogin_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (Globals.Validator.IsValidShortName(tbLoginName.Text) && Globals.Validator.LoginName_Check(tbLoginName.Text))
         {
             loginUser = Globals.simpleJiraDB.Users.Where(u => u.LoginName == tbLoginName.Text).FirstOrDefault();
             if (loginUser != null)
             {
                 string pwd = SecurePassword.Decrypt(loginUser.PWDEncrypted);
                 if (tbPassword.Password.Equals(pwd))
                 {
                     LoginCallback?.Invoke(loginUser);
                     this.Close();
                     new MainWindow(loginUser).ShowDialog();
                 }
                 else
                 {
                     new MessageBoxCustom("Password Incorrect", MessageBoxCustom.MessageType.Info, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
                 }
             }
         }
         else
         {
             new MessageBoxCustom("User not exist", MessageBoxCustom.MessageType.Info, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
         }
     }
     catch (SqlException ex)
     {
         new MessageBoxCustom("Error Login into system:\n" + ex.Message, MessageBoxCustom.MessageType.Error, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Sends a generic login request
        /// </summary>
        public void LogIn(Dictionary <string, string> data, LoginCallback callback, IClientSocket connection)
        {
            if (!connection.IsConnected)
            {
                callback.Invoke(null, "Not connected to server");
                return;
            }

            _isLogginIn = true;

            // We first need to get an aes key
            // so that we can encrypt our login data
            Msf.Security.GetAesKey(aesKey =>
            {
                if (aesKey == null)
                {
                    _isLogginIn = false;
                    callback.Invoke(null, "Failed to log in due to security issues");
                    return;
                }

                var encryptedData = Msf.Security.EncryptAES(data.ToBytes(), aesKey);

                connection.SendMessage((short)MsfOpCodes.LogIn, encryptedData, (status, response) =>
                {
                    _isLogginIn = false;

                    if (status != ResponseStatus.Success)
                    {
                        callback.Invoke(null, response.AsString("Unknown error"));
                        return;
                    }

                    IsLoggedIn = true;

                    AccountInfo = response.Deserialize(new AccountInfoPacket());

                    callback.Invoke(AccountInfo, null);

                    if (LoggedIn != null)
                    {
                        LoggedIn.Invoke();
                    }
                });
            }, connection);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sends a generic login request
        /// </summary>
        public void LogIn(Dictionary <string, string> data, LoginCallback callback, ErrorCallback errorCallback)
        {
            if (!Client.IsConnected)
            {
                errorCallback.Invoke("Not connected to server");
                return;
            }

            _isLoggingIn = true;

            // We first need to get an aes key
            // so that we can encrypt our login data
            _securityPlugin.GetAesKey(aesKey =>
            {
                if (aesKey == null)
                {
                    _isLoggingIn = false;
                    errorCallback.Invoke("Failed to log in due to security issues");
                    return;
                }

                var encryptedData = Util.EncryptAES(data.ToBytes(), aesKey);

                Client.SendMessage((ushort)OpCodes.LogIn, encryptedData, (status, response) =>
                {
                    _isLoggingIn = false;

                    if (status != ResponseStatus.Success)
                    {
                        errorCallback.Invoke(response.AsString("Unknown error"));
                        return;
                    }

                    IsLoggedIn = true;

                    AccountInfo = response.Deserialize <AccountInfoPacket>();

                    callback.Invoke(AccountInfo);
                });
            });
        }
Ejemplo n.º 6
0
 private void OnLoginFailed()
 {
     OnLoginCallback?.Invoke(LoginStatus.Failed);
 }
        private void Steam_DataReceived(object sender, string e)
        {
            if (string.IsNullOrEmpty(e))
            {
                return;
            }
            string line = e;

            Console.WriteLine(e);

            SteamOutput?.Invoke(this, line);

            if (line.Equals("Loading Steam API...OK."))
            {
                waitStartAsync.Set();
                //SteamExited?.Invoke(this, SteamExitReason.NonEnglishCharachers);
            }
            else if (line.Contains("cannot run from a folder path that includes non-English characters"))
            {
                close(SteamExitReason.NonEnglishCharachers);
            }
            else if (line.Equals("FAILED with result code 5") | line.Equals("Login with cached credentials FAILED with result code 5"))
            {
                LoginCallback?.Invoke(this, LoginResult.WrongInformation);
            }
            else if (line.Equals("FAILED with result code 88"))
            {
                LoginCallback?.Invoke(this, LoginResult.SteamGuardCodeWrong);
            }
            else if (line.Equals("FAILED with result code 65"))
            {
                LoginCallback?.Invoke(this, LoginResult.SteamGuardCodeWrong);
            }
            else if (line.Equals("FAILED with result code 71"))
            {
                LoginCallback?.Invoke(this, LoginResult.ExpiredCode);
            }
            else if (line.Equals("FAILED with result code 84"))
            {
                LoginCallback?.Invoke(this, LoginResult.RateLimitedExceeded);
            }
            else if (line.Contains("using 'set_steam_guard_code'"))
            {
                LoginCallback?.Invoke(this, LoginResult.SteamGuardNotSupported);
            }
            else if (line.Contains("Enter the current code from your Steam Guard Mobile Authenticator app"))
            {
                LoginCallback?.Invoke(this, LoginResult.WaitingForSteamGuard);
            }
            else if (line.Contains("FAILED with result code 50"))
            {
                LoginCallback?.Invoke(this, LoginResult.AlreadyLoggedIn);
            }
            else if (LoginState == false & (line.Contains("Waiting for license info...OK") | line.Contains("Logged in OK")))
            {
                LoginState = true;
                LoginCallback?.Invoke(this, LoginResult.OK);
            }
            else if (Regex.IsMatch(line, "ERROR! Download item [0-9]+ failed (Access Denied)."))
            {
                ModDownloaded?.Invoke(this, null);
            }
            else if (Regex.IsMatch(line, "Error! App '[0-9]+' state is 0x[0-9]+ after update job."))
            {
                AppUpdated?.Invoke(true);
            }
            else if (Regex.IsMatch(line, @"Update state \(0x5\) validating, progress: ([0-9]+)\.([0-9]+) \(([0-9]+) / ([0-9]+)\)"))
            {
                Regex pattern = new Regex(@"Update state \(0x5\) validating, progress: ([0-9]+)\.([0-9]+) \(([0-9]+) / ([0-9]+)\)");
                Match match   = pattern.Match(line);


                SteamAppUpdateState state = new SteamAppUpdateState();
                state.percentage    = Convert.ToInt32(match.Groups[1].Value);
                state.receivedBytes = Convert.ToInt64(match.Groups[3].Value);
                state.totalBytes    = Convert.ToInt64(match.Groups[4].Value);
                state.stage         = UpdateStateStage.Validating;

                AppUpdateStateChanged?.Invoke(this, state);
            }
            else if (Regex.IsMatch(line, @"Update state \(0x61\) downloading, progress: ([0-9]+)\.([0-9]+) \(([0-9]+) / ([0-9]+)\)"))
            {
                Regex pattern = new Regex(@"Update state \(0x61\) downloading, progress: ([0-9]+)\.([0-9]+) \(([0-9]+) / ([0-9]+)\)");
                Match match   = pattern.Match(line);


                SteamAppUpdateState state = new SteamAppUpdateState();
                state.percentage    = Convert.ToInt32(match.Groups[1].Value);
                state.receivedBytes = Convert.ToInt64(match.Groups[3].Value);
                state.totalBytes    = Convert.ToInt64(match.Groups[4].Value);
                state.stage         = UpdateStateStage.Downloading;

                AppUpdateStateChanged?.Invoke(this, state);
            }
            else if (Regex.IsMatch(line, @"Update state \(0x81\) commiting, progress: ([0-9]+)\.([0-9]+) \(([0-9]+) / ([0-9]+)\)"))
            {
                Regex pattern = new Regex(@"Update state \(0x81\) commiting, progress: ([0-9]+)\.([0-9]+) \(([0-9]+) / ([0-9]+)\)");
                Match match   = pattern.Match(line);


                SteamAppUpdateState state = new SteamAppUpdateState();
                state.percentage    = Convert.ToInt32(match.Groups[1].Value);
                state.receivedBytes = Convert.ToInt64(match.Groups[3].Value);
                state.totalBytes    = Convert.ToInt64(match.Groups[4].Value);
                state.stage         = UpdateStateStage.Commiting;

                AppUpdateStateChanged?.Invoke(this, state);
            }
            else if (Regex.IsMatch(line, @"Update state \(0x11\) preallocating, progress: ([0-9]+)\.([0-9]+) \(([0-9]+) / ([0-9]+)\)"))
            {
                Regex pattern = new Regex(@"Update state \(0x11\) preallocating, progress: ([0-9]+)\.([0-9]+) \(([0-9]+) / ([0-9]+)\)");
                Match match   = pattern.Match(line);


                SteamAppUpdateState state = new SteamAppUpdateState();
                state.percentage    = Convert.ToInt32(match.Groups[1].Value);
                state.receivedBytes = Convert.ToInt64(match.Groups[3].Value);
                state.totalBytes    = Convert.ToInt64(match.Groups[4].Value);
                state.stage         = UpdateStateStage.Preallocating;
                AppUpdateStateChanged?.Invoke(this, state);
            }
            else if (line.Contains("Success! App '") & line.Contains("' fully installed."))
            {
                AppUpdated?.Invoke(this);
            }
            else if (line.Contains("Success! App '") & line.Contains("' already up to date."))
            {
                AppUpdated?.Invoke(this);
            }
            else if (line.Contains("Success. Downloaded item") & line.Contains("bytes"))
            {
                ModDownloaded?.Invoke(this, line.Split('"')[1]);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Callback to login button.
 /// </summary>
 /// <param name="sender"></param>
 private void LoginCallbackHandler(object sender)
 {
     LoginCallback?.Invoke(sender);
 }
Ejemplo n.º 9
0
        private IEnumerator OnLoginResponse(string url, Dictionary <string, string> formData, LoginCallback cb, string userName, string gameVersion)
        {
            using (UnityWebRequest request = WebConfig.Post(url, formData))
            {
                yield return(request.SendWebRequest());

                m_WebCoroutine = null;

                ErrorResponse error = WebConfig.ProcessGenericErrors(request);

                if (error != null)
                {
                    cb?.Invoke(new LoginResponse(), error);
                    yield break;
                }

                LoginResponse response = LoginResponse.FromJson(request.downloadHandler.text);

                switch (response.code)
                {
                case 1:
                    // Save remember me credentials
                    PlayerPrefs.SetInt("FlexAS_Login_RememberMe", !string.IsNullOrEmpty(response.rememberMeToken) ? 1 : 0);
                    if (!string.IsNullOrEmpty(response.rememberMeToken))
                    {
                        PlayerPrefs.SetString("FlexAS_Login_UserName", userName);
                        PlayerPrefs.SetString("FlexAS_Login_RememberMeToken", response.rememberMeToken);
                    }
                    PlayerPrefs.Save();

                    cb?.Invoke(response, null);

                    break;

                case 2:
                    cb?.Invoke(response, new ErrorResponse("Your app version is out of date.\n\nCurrent Version: " + response.serverVersion + "\nYour Version: " + gameVersion,
                                                           response.message, null, response.code));
                    break;

                case 5:
                    string accountRestoreTime = "";
                    if (response.banRestoreDate > 0)
                    {
                        accountRestoreTime = "\n\nAccount will be restored in " + DateUtility.GetFormattedTimeFromSeconds(response.banRestoreDate);
                    }
                    cb?.Invoke(response, new ErrorResponse("This account has been banned.\n\nAdmin Message:\n\"" + response.banReason + "\"" + accountRestoreTime, response.message, null, response.code));
                    break;

                case 3: cb?.Invoke(response, new ErrorResponse("Incorrect username or password", response.message, null, response.code));       break;

                case 4: cb?.Invoke(response, new ErrorResponse("Account Locked", response.message, null, response.code));                                       break;

                case 6:
                    // Down for maintenance
                    cb?.Invoke(response, new ErrorResponse(response.message, response.displayMessage, null, response.code));
                    break;

                default:
                    // Unknown code error
                    cb?.Invoke(response, WebConfig.GetUnknownError(request));
                    break;
                }
            }
        }