Ejemplo n.º 1
0
        /// <summary>
        /// Starts the New Alias request.
        /// </summary>
        /// <param name="platform_id">ID of platform in Ebenit API to run the request to.</param>
        /// <param name="email">User e-mail.</param>
        /// <param name="nickname">User nickname.</param>
        /// <param name="password">User password in plain text.</param>
        /// <param name="password_check">User password in plain text. Recommended from other input box to verify the correctness of password.</param>
        /// <param name="result_method">Delegate method to store the request result.</param>
        /// <returns>True - if the request was successfuly started. False - otherwise.</returns>
        public bool userNewAlias(uint platform_id, string email, string nickname, string password, string password_check, SetNewAliasResult result_method)
        {
            this.pt_platform_id = platform_id;

            if (string.IsNullOrEmpty(email) || !Regex.IsMatch(email, @"^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$") || string.IsNullOrEmpty(nickname) ||
                string.IsNullOrEmpty(password) || string.IsNullOrEmpty(password_check) ||
                !password.Equals(password_check)
                )
            {
                result_method(NewAliasResult.INCORRECT_DATA_ERROR);
                return(false);
            }

            result_method(NewAliasResult.NOT_FINISHED);

            StartCoroutine(doUserNewAlias(email, nickname, password, password_check, result_method));

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Coroutine to send the New Alias request and handle it.
        /// </summary>
        /// <param name="email">User e-mail.</param>
        /// <param name="nickname">User nickname.</param>
        /// <param name="password">User password in plain text.</param>
        /// <param name="password_check">User password in plain text. Recommended from other input box to verify the correctness of password.</param>
        /// <param name="result_method">Delegate method to store the request result.</param>
        /// <returns></returns>
        private IEnumerator doUserNewAlias(string email, string nickname, string password, string password_check, SetNewAliasResult result_method)
        {
            var request = RequestManager.getInstance().createUserNewAliasRequest(email, nickname, password, password_check);

            yield return(request.send());

            var response = request.pt_response as UserNewAliasResponse;

            NewAliasResult alias_result = NewAliasResult.UNKNOWN_ERROR;

            if (response == null)
            {
                alias_result = NewAliasResult.UNKNOWN_ERROR;
            }
            else if (response.results != null && response.results.success)
            {
                alias_result = NewAliasResult.SUCCESSFUL;
            }
            else if (response.errors != null)
            {
                if (response.errors.incorrectData)
                {
                    alias_result = NewAliasResult.INCORRECT_DATA_ERROR;
                }
                else if (response.errors.platform)
                {
                    alias_result = NewAliasResult.PLATFORM_ERROR;
                }
                else if (response.errors.user)
                {
                    alias_result = NewAliasResult.USER_ERROR;
                }
                else if (response.errors.password)
                {
                    alias_result = NewAliasResult.PASSWORD_ERROR;
                }
                else
                {
                    alias_result = NewAliasResult.COMMUNICATION_ERROR;
                }
            }
            else
            {
                alias_result = NewAliasResult.UNKNOWN_ERROR;
            }

            result_method(alias_result);
        }