Any password works - Mysql
#1

pawn Код:
function InitiateLogin(playerid)
{
    new
        szQuery2[1024],
        str[1024];
    if(mysql_num_rows() > 0)
            {
                if(mysql_fetch_row(szQuery2)) { sscanf(str, "e<p<|>s[24]s[64]ddddfffdddddddddddddddddddddds[16]dddddd>", PlayerInfo[playerid]); }
               
             }
           else
            {
                SendClientMessage(playerid, -1, "[::] Invalid password. Please try again.");
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "[::] Login", "Your password was incorrect, try again.", "Login", "");
                return 0;
            }
    mysql_free_result();
    return 1;
 }
No matter what password I use, I could login to the account.. Thanks for any help in advance
Reply
#2

remove mysql_query(szQuery2); from the query
Reply
#3

Could we see your initial query?
Reply
#4

I actually used part of your tutorial for this, I'm also having an issue where it only says login, while the account doesn't exist. I'll show the onplayerconnect and login dialog code.

OnPlayerConnect
pawn Код:
format(str,sizeof(str),"SELECT * FROM "SQL_ACCOUNT_TABLE" WHERE User = '%s'",pName2(playerid));
    mysql_query(str);
    mysql_store_result();
    if (mysql_num_rows() == 1)
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "[::] Login", "Please enter your password below to login.", "Login", "");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "[::] Register", "Please enter your password below to register.", "Register", "");
    }

And the Login Dialog:
pawn Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                new
                    HashedPW[145],
                    str[1024];
               
                mysql_real_escape_string(inputtext, HashedPW);
                WP_Hash(HashedPW, sizeof (HashedPW), inputtext);
                format(str, sizeof(str), "SELECT * FROM "SQL_ACCOUNT_TABLE" WHERE User = '%s' AND pPass = '%s'", pName2(playerid), HashedPW);
                mysql_query(str);
                InitiateLogin(playerid);
            }
        }
Reply
#5

Use mysql_debug(1); under OnGameModeInit and show us what those queries are returning in the debug.
Reply
#6

pawn Код:
[17:43:03] CMySQLHandler::Query(SELECT * FROM Accounts WHERE User = 'Henry_DeJesus') - Successfully executed.

[17:43:03] >> mysql_store_result( Connection handle: 1 )

[17:43:03] CMySQLHandler::StoreResult() - Result was stored.

[17:43:03] >> mysql_num_rows( Connection handle: 1 )

[17:43:03] CMySQLHandler::NumRows() - Returned 1 row(s)

[17:43:50] >> mysql_real_escape_string( Connection handle: 1 )

[17:43:50] CMySQLHandler::EscapeString(killer); - Escaped 6 characters to killer.

[17:43:50] >> mysql_query( Connection handle: 1 )

[17:43:50] CMySQLHandler::Query(SELECT * FROM Accounts WHERE User = 'Henry_DeJesus' AND pPass = 'ED98CCB6BCD9CC82012A9561B4DB8E39E91C16C0491A150CC2700740203C388A1DC05C723DA4B609BCD8F5CE20B5FB640723D589E0D48B4BB9C0A95999CF1D30') - Successfully executed.

[17:43:50] >> mysql_num_rows( Connection handle: 1 )

[17:43:50] CMySQLHandler::NumRows() - Returned 1 row(s)

[17:43:50] >> mysql_fetch_row_format( Connection handle: 1 )

[17:43:50] CMySQLHandler::FetchRow() - Return: Henry_DeJesus|ED98CCB6BCD9CC82012A9561B4DB8E39E91C16C04|0|0|0|0|0|0|-61.5984|0|0|0|1819281969|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0||0|0|0|4|0|0

[17:43:50] >> mysql_free_result( Connection handle: 1 )

[17:43:50] CMySQLHandler::FreeResult() - Result was successfully free'd.
Reply
#7

I'm not sure that this is fully the issue, but you are only loading and saving half of the whirlpool password by the looks of it. You are querying

Код:
ED98CCB6BCD9CC82012A9561B4DB8E39E91C16C0491A150CC2700740203C388A1DC05C723DA4B609BCD8F5CE20B5FB640723D589E0D48B4BB9C0A95999CF1D30
Yet it's retrieving
Код:
ED98CCB6BCD9CC82012A9561B4DB8E39E91C16C04
From the database.
Reply
#8

Yeah, I noticed that part, could that be the only cause?
Reply
#9

I fixed the length, and it loads/saves the full password now, but look at the difference:

CORRECT PASS:
pawn Код:
DCCCF47FC70C1EA7B23E86F78DB61252A37ECB9A2C4454EBB98E9D4E72A0C6292C95A23446AD584104596B16031B0C67C4C036B9FA4383FD49EC013624AD225C
Random pass that worked:
pawn Код:
92E35CD15919B567491A5564FE8C730E1D91295FAFB8202E5DF67EA642F3D0B188AA0A0792492245F5B24AE7E1AB5B7C0341A88E2974D86ABA63B6106858FC9F
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)