Any password or no password accepted.
#1

pawn Код:
if(dialogid == LOGIN_DIALOG)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
        }
        else
        {
            new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(!strcmp(escapedPassword,PlayerInfo[playerid][pPass],true))
            {
                SendClientMessage(playerid, -1, "Incorrect Password Entered - Please try again.");
                ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
            }
            else
            {
                format(GlobalString, sizeof(GlobalString), "Welcome "COL_LIGHTBLUE"%s!",GetName(playerid));
                SendClientMessage(playerid, -1, GlobalString);

                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);

                TogglePlayerSpectating(playerid, false);
            }
My problem is this part:
pawn Код:
new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(!strcmp(escapedPassword,PlayerInfo[playerid][pPass],true))
Any password or no password allows you into the account.
Reply
#2

That boolean is the ignore case. When set to true, it ignores case sensitivity.

pawn Код:
if(!strcmp(escapedPassword,PlayerInfo[playerid][pPass],false)
Reply
#3

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
That boolean is the ignore case. When set to true, it ignores case sensitivity.

pawn Код:
if(!strcmp(escapedPassword,PlayerInfo[playerid][pPass],false)
Still, any password is accepted.
Reply
#4

Strcmp returns 0 if the strings you compare match and 1/-1 if they don't. So bassicaly if you introduce your good password you won't be able to login. Change the if condition
pawn Код:
if(dialogid == LOGIN_DIALOG)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
        }
        else
        {
            new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(strcmp(escapedPassword,PlayerInfo[playerid][pPass],true))
            {
                SendClientMessage(playerid, -1, "Incorrect Password Entered - Please try again.");
                ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
            }
            else
            {
                format(GlobalString, sizeof(GlobalString), "Welcome "COL_LIGHTBLUE"%s!",GetName(playerid));
                SendClientMessage(playerid, -1, GlobalString);

                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);

                TogglePlayerSpectating(playerid, false);
            }
https://sampwiki.blast.hk/wiki/Strcmp
Reply
#5

Quote:
Originally Posted by Koala818
Посмотреть сообщение
Strcmp returns 0 if the strings you compare match and 1/-1 if they don't. So bassicaly if you introduce your good password you won't be able to login. Change the if condition
pawn Код:
if(dialogid == LOGIN_DIALOG)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
        }
        else
        {
            new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(strcmp(escapedPassword,PlayerInfo[playerid][pPass],true))
            {
                SendClientMessage(playerid, -1, "Incorrect Password Entered - Please try again.");
                ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
            }
            else
            {
                format(GlobalString, sizeof(GlobalString), "Welcome "COL_LIGHTBLUE"%s!",GetName(playerid));
                SendClientMessage(playerid, -1, GlobalString);

                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);

                TogglePlayerSpectating(playerid, false);
            }
https://sampwiki.blast.hk/wiki/Strcmp
Now nothing lets me log in. Even the correct password or no password.
Reply
#6

Quote:
Originally Posted by Koala818
Посмотреть сообщение
Strcmp returns 0 if the strings you compare match and 1/-1 if they don't. So bassicaly if you introduce your good password you won't be able to login.
Oh I misread that. Remove the exclamation point, and change your "true" to "false."
Reply
#7

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
Oh I misread that. Remove the exclamation point, and change your "true" to "false."
Still the same, nothing allows me to login.

EDIT:
pawn Код:
if(dialogid == LOGIN_DIALOG)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
        }
        else
        {
            new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(strcmp(escapedPassword,PlayerInfo[playerid][pPass],false))
            {
                SendClientMessage(playerid, -1, "Incorrect Password Entered - Please try again.");
                ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
            }
            else
            {
                LoadPlayer(playerid);
                format(GlobalString, sizeof(GlobalString), "Welcome "COL_LIGHTBLUE"%s!",GetName(playerid));
                SendClientMessage(playerid, -1, GlobalString);

                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                mysql_format(sqldb, query, sizeof(query), "SELECT * FROM vehicles WHERE owner = '%s'", GetName(playerid));
                mysql_tquery(sqldb, query, "VehicleCheck", "i", playerid);

                TogglePlayerSpectating(playerid, false);
            }
        }
        return 1;
    }
Reply
#8

Add this code to check if [pPass] is not empty:

pawn Код:
printf("Password Length: %d", strlen(PlayerInfo[playerid][pPass]));
Reply
#9

IT's reading 23. The hash is 24 characters long and my password is 6 in total.
Reply
#10

That isn't correct. pPass should be 129 characters (as WP_Hash hashes the string to 129 characters), and the newly hashed password should be 129 characters also... Are you actually using Whirlpool or have you just renamed a function?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)