예제 #1
0
    /// <summary>
    /// Updates the timer text and checks to see if the user can be granted access to the password field again,
    /// or gets the full login attempts amount reset again
    /// </summary>
    /// <returns> Returns one WaitForSeconds </returns>
    private IEnumerator TimerChecker()
    {
        long currentTime, lastFailedAttempt;

        long.TryParse(DateTimeUtils.GetCurrentUnixTime().ToString(), out currentTime);
        long.TryParse(SecurePlayerPrefs.GetString(walletName + PlayerPrefConstants.SETTING_LAST_FAILED_LOGIN_ATTEMPT), out lastFailedAttempt);

        if ((currentTime - lastFailedAttempt) >= 300)
        {
            SecurePlayerPrefs.SetInt(walletName + PlayerPrefConstants.SETTING_CURRENT_LOGIN_ATTEMPT, 1);
            passwordField.SetPlaceholderText("Password");

            if (lockedOut)
            {
                lockedOut          = false;
                passwordField.Text = string.Empty;
                passwordField.UpdateVisuals();
                passwordField.InputFieldBase.ActivateInputField();
                AnimateLockedOutSection?.Invoke(false);
            }
        }
        else
        {
            timerText.text = DateTimeUtils.GetAnalogTime(300 - (currentTime - lastFailedAttempt));
        }

        yield return(waiter);

        if (this != null)
        {
            TimerChecker().StartCoroutine();
        }
    }
예제 #2
0
    /// <summary>
    /// The password is incorrect and the user is given an error
    /// </summary>
    private void IncorrectPassword()
    {
        OnPasswordEnteredIncorrect?.Invoke();

        if (!SecurePlayerPrefs.GetBool(PlayerPrefConstants.SETTING_LOGIN_ATTEMPTS_LIMIT))
        {
            return;
        }

        SecurePlayerPrefs.SetInt(walletName + PlayerPrefConstants.SETTING_CURRENT_LOGIN_ATTEMPT, SecurePlayerPrefs.GetInt(walletName + PlayerPrefConstants.SETTING_CURRENT_LOGIN_ATTEMPT) + 1);
        SecurePlayerPrefs.SetString(walletName + PlayerPrefConstants.SETTING_LAST_FAILED_LOGIN_ATTEMPT, DateTimeUtils.GetCurrentUnixTime().ToString());

        if ((SecurePlayerPrefs.GetInt(PlayerPrefConstants.SETTING_MAX_LOGIN_ATTEMPTS) - SecurePlayerPrefs.GetInt(walletName + PlayerPrefConstants.SETTING_CURRENT_LOGIN_ATTEMPT) + 1) == 0)
        {
            lockedOut = true;
            AnimateLockedOutSection?.Invoke(true);
        }
        else
        {
            UpdatePlaceHolderText();
        }
    }