예제 #1
0
    public void OnSubmit()
    {
        // disable error messages if was
        ErrorTextEmail.gameObject.SetActive(false);
        ErrorTextPassword.gameObject.SetActive(false);

        // read form
        string email    = Email.text;
        string password = Password.text;

        bool errorFlag = false;

        // validate email
        if (!AccountsUtil.EmailIsValid(email))
        {
            ErrorTextEmail.text = "Пожалуйста, введите существующий адрес";
            ErrorTextEmail.gameObject.SetActive(true);
            errorFlag = true;
        }

        // validate pass
        if (password.Length < 6)
        {
            ErrorTextPassword.text = "Введите пароль";
            ErrorTextPassword.gameObject.SetActive(true);
            errorFlag = true;
        }


        // if everything went okay
        if (!errorFlag)
        {
            LoginManager.Instance.LoginEmail(Email.text, Password.text);
        }
    }
예제 #2
0
        /// <summary>
        /// Validated new account data
        /// </summary>
        private static AccountReturnCodes ValidateNewAccount(string nickname, string email, string password)
        {
            // check nickname validity
            if (!AccountsUtil.NicknameValid(nickname))
            {
                return(AccountReturnCodes.NicknameIsInvalid);
            }

            // check email validity
            if (!AccountsUtil.EmailIsValid(email))
            {
                return(AccountReturnCodes.EmailIsInvalid);
            }

            // check email used
            if (AccountsUtil.EmailUsed(email))
            {
                return(AccountReturnCodes.EmailUsed);
            }

            // check password validity
            if (!AccountsUtil.PasswordValid(password))
            {
                return(AccountReturnCodes.PasswordIsInvalid);
            }

            return(AccountReturnCodes.Ok);
        }
    public void OnSubmit()
    {
        // disable error messages if was
        ErrorTextNickname.gameObject.SetActive(false);
        ErrorTextEmail.gameObject.SetActive(false);
        ErrorTextPassword.gameObject.SetActive(false);

        // read form
        string nickname       = Nickname.text;
        string email          = Email.text;
        string password       = Password.text;
        string passwordRepeat = PasswordRepeat.text;


        bool errorFlag = false;

        // validate name
        if (!NicknameIsValid(nickname))
        {
            ErrorTextNickname.text = "Имя должно содержать больше 2х символов";
            ErrorTextNickname.gameObject.SetActive(true);
            errorFlag = true;
        }

        // validate email
        if (!AccountsUtil.EmailIsValid(email))
        {
            ErrorTextEmail.text = "Пожалуйста, введите существующий адрес";
            ErrorTextEmail.gameObject.SetActive(true);
            errorFlag = true;
        }

        // validate pass
        if (password.Length < 6)
        {
            ErrorTextPassword.text = "Придумайте пароль длиннее 6-ти символов";
            ErrorTextPassword.gameObject.SetActive(true);
            errorFlag = true;
        }
        else if (passwordRepeat.Length == 0)
        {
            ErrorTextPassword.text = "Повторите пароль ниже";
            ErrorTextPassword.gameObject.SetActive(true);
            errorFlag = true;
        }
        else if (password != passwordRepeat)
        {
            ErrorTextPassword.text = "Пароли не совпадают";
            ErrorTextPassword.gameObject.SetActive(true);
            errorFlag = true;
        }

        if (!errorFlag)
        {
            LoginManager.Instance.RegisterEmail(nickname, email, password);
        }
    }
예제 #4
0
    /// <summary>
    /// Send login data to server
    /// Data needs to be pre-checked
    /// </summary>
    public void LoginEmail(string email, string password)
    {
        this.Email           = email;
        this.Password        = password;
        this.LastLoginMethod = "Email";


        string sha1password = AccountsUtil.GetSha1(password);

        AccountPackets.SendEmailLogin(email, sha1password);
    }
예제 #5
0
    /// <summary>
    /// Send registerq data to server
    /// Data needs to be pre-checked
    /// </summary>
    public void RegisterEmail(string nickname, string email, string password)
    {
        this.Email           = email;
        this.Password        = password;
        this.LastLoginMethod = "Email";


        string sha1password = AccountsUtil.GetSha1(password);

        AccountPackets.SendEmailRegistration(nickname, email, sha1password);
    }