Home > Enterprise >  theres weird small space getting in my password input field
theres weird small space getting in my password input field

Time:10-25

i'm trying to make login page for my game so I can track everything.. anyway I have enough knoldgke to build it using php and c# to configure the connection to the database... everything here is fine...

but i got always invalid password error even when the password is right (using password_verify - password_hash) I track it on php first to see maybe the query having errors but it was completely fine I went then to sql made password without hashing just normal password also i'm getting same error so the last thing was unity c#.. i checked the code it was fine (tracking it by letting it print the user and pass every process) but i noticed that from the beginning before the password sent from input field to php file there's small space that not even a space it's something weird I tried to copy it but nothing shows it doesn't even make space but it's there.. I tried to send password by writing it from string inside the code not from UI it printed normal but whenever I use input field It has same problem (keep in mind: username field has no problems) so i tried to make new field or copying username field.. same thing here's a picture : enter image description here

here's video also : enter image description here

after : enter image description here

video after write password manually : Click here2 i tried all functions for deleting spaces it doesn't even recognized as space

    public class ButtonVerify : MonoBehaviour
{
    public Button SubmitButton;
    public TMP_Text username;
    public TMP_Text password;
// Start is called before the first frame update
void Start()
{
    Button btn = SubmitButton.GetComponent<Button>();
    btn.onClick.AddListener(TaskOnClick);
}

void TaskOnClick()
{
    StartCoroutine(Login(username.text.ToString(), password.text.ToString()));
}
IEnumerator Login(string user_email, string user_pass)
{
    WWWForm form = new WWWForm();
    form.AddField("loginEmail", user_email);
    form.AddField("loginPassword", user_pass);

    using (UnityWebRequest www = UnityWebRequest.Post("imagine_theres_url",form))
    {
        yield return www.SendWebRequest();

        if(www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log(www.downloadHandler.text);
        }
    }

}

}

CodePudding user response:

I agree with [gunr2171][1] in saying that you have not provided sufficient information for an explicit answer. But I will go out on a limb and provide a vague diagnosis which may or may not be accurate.

Is it it possible that the extra 'space' at the end, highlighted by the blue line does in fact represent a special ENDING character (see [1] below) that is supposed to end the password input but not be part of it?

How would you know? As always, you can EITHER AVOID the suspected circumstance, OR INSPECT the suspected circumstance. Here are possible ways to do each of those.

AVOID

If it is possible through your input interface, do this:

  1. Type the complete password AND NOTHING ELSE.
  2. DO NOT type any of the special ENDING characters listed in 1 below.
  3. Use a mouse click to move on to the next field or button.

If the problem went away, then you will need the fix described in 3 below. Otherwise, if the outcome is still bad or if you cannot perform that test on your interface, then try my next suggestion ...

INSPECT

Inspect every individual character in the password and verify that its (ASCII or Unicode) VALUE is a number greater than the VALUE for the space[2] character. You could help the process by testing with an invented user with a password of just 1 character (or zero?)

If any are password characters are LESS THAN a space character (VALUE 32) (in particular the last one), then you need the fix described in 3 below.

If every individual character is password-acceptable, then the solution must lie elsewhere. You will need to provide more details (e.g. what functions you are using to obtain the user's typed password).

  1. By ENDING characters, I mean things like 'Enter' (new-line and or carriage-return characters) or 'Tab'.

  2. This SPACE character in my RESPONSE is only coincidentally the same as the character you SUSPECT. I am using it because its VALUE marks the boundary between the control characters not allowed in passwords, and the generally allowed characters.

  3. If you were directed here, then you need to remove the offending character(s) - ones with a VALUE less that the SPACE character. Usually, there is an function that will do that automatically with your password string.

CodePudding user response:

This is a know "issue"! See e.g. here

The TMP_Inputfield sometimes adds a trailing invisible control char but only in the underlying TMP_Text component.


The solution:

Instead of directly going through the TMP_Text component of the TMP_InputField rather always go through its TMP_Inputfield.text property which removes those additional chars!

public TMP_InputField username;
public TMP_InputField password;

an then this should do the trick

StartCoroutine(Login(username.text, password.text));

Btw there is no need for calling ToString on, well, a string ;)

  • Related