Whirpool help won't work on login.
#1

pawn Код:
public LoadUser_data(playerid, name[], value[]) //new function with playerid, player name and value
{
    INI_String("Password", PlayerInfo[playerid][Password], 129);
Dialog register
pawn Код:
new hashPassword[129];
             // WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
                WP_Hash(hashPassword, 129, inputtext);
                new
                    uFile[35]; //variable for file

                format(uFile, 35, USER_FILE, GetName(playerid));
                new
                INI:playerFile = INI_Open(uFile);
                INI_SetTag(playerFile,"DATA");
                INI_WriteString(playerFile, "Password", hashPassword);
dialog login
pawn Код:
new hashPassword[129];
            //  new inputtext = strval(inputtext);
        //      WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
            //  WP_Hash(inputtext,sizeof(inputtext),hashPassword);
                WP_Hash(hashPassword, 129, inputtext);
                //WP_Hash(wpHash, sizeof(wpHash), inputtext);
                if(!strcmp(inputtext,PlayerInfo[playerid][Password]))return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
I tried all solutions to load the password on login but it keep saying wrong password. Best i got is that i can login with any pass. Anyone has idea where i'm making mistake??

Thanks
Reply
#2

Print out the passwords when you load them from the user file also print after you hash at the login. Check if they match.
Reply
#3

B8862519622BF4035CAE23DA0F7D045F3B83C68D0D5E8BEF3B 3CF3E5F93B7F377C6499D7C344ABC24141947AF907AD05CD73 C31ADACBDAE25C9584085621D086
B8862519622BF4035CAE23DA0F7D045F3B83C68D0D5E8BEF3B 3CF3E5F93B7F377C6499D7C344ABC24141947AF907AD05CD73 C31ADACBDAE25C9584085621D086

Same
Reply
#4

if(!strcmp(inputtext,PlayerInfo[playerid][Password]))return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"Yo u have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");

translating this to human language:

if the inputtext equals to the password, it shows him the dialog saying password incorrect.
Reply
#5

pawn Код:
if(!strcmp(hashPassword, PlayerInfo[playerid][Password], true))
{
    //Put what happens when the correct password is filled in.
}
else
{
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have     entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
    return 0;
}
You were using the non hashed string to compare to, and you were mistaking with the return value of strcmp. Sorry I did not notice this the first time, it should work now.

Also don't use return ShowPlayerDialog, just because ShowPlayerDialog returns a value it doesn't mean it's the correct value, it just doesn't make sense. Return 0 (just ending the function) would be better in this case.

Edit: Kiroloss beat me to it, gotta love the wait between post time haha.
Reply
#6

It is the same i can login with any password (:

pawn Код:
case DIALOG_LOGIN:
        {
            if (!response ) return Kick ( playerid );
            if( response )
            {
        //      WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
            //  WP_Hash(inputtext,sizeof(inputtext),hashPassword);
                new hashPassword[129],uFile[35];
            //  WP_Hash(hashPassword, 129, inputtext);
                //WP_Hash(wpHash, sizeof(wpHash), inputtext);
                WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
                printf(hashPassword);
                if(!strcmp(hashPassword, PlayerInfo[playerid][Password], true))
                {
            //  if(PlayerInfo[playerid][pBanned]== 1)
            //      {
            //      SendClientMessage(playerid, COLOR_YELLOW, "********************************Your account has been banned, please apply on our forums request for unban!*********************************");
            //      Kick(playerid);
            //      }
                    format(uFile, 35, USER_FILE, GetName(playerid));
                    INI_ParseFile(uFile, "LoadUser_user", .bExtra = true, .extra = playerid);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                    SetPVarInt(playerid, "Logged", 1);
                }
                else
                {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have     entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                 return 0;
                }
           
            }
        }
Reply
#7

Try like this
pawn Код:
case DIALOG_LOGIN:
        {
            if (!response ) return Kick ( playerid );
            if( response )
            {
                new hashPassword[129];
                WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
                if(!strcmp(hashPassword, PlayerInfo[playerid][Password]))
                {
                    format(uFile, 35, USER_FILE, GetName(playerid));
                    INI_ParseFile(uFile, "LoadUser_user", .bExtra = true, .extra = playerid);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                    SetPVarInt(playerid, "Logged", 1);
                }
                else
                {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have     entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                return 1;
                }
           
            }
        }
Reply
#8

Quote:
Originally Posted by MarkoN
Посмотреть сообщение
Try like this
pawn Код:
case DIALOG_LOGIN:
        {
            if (!response ) return Kick ( playerid );
            if( response )
            {
                new hashPassword[129];
                WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
                if(!strcmp(hashPassword, PlayerInfo[playerid][Password]))
                {
                    format(uFile, 35, USER_FILE, GetName(playerid));
                    INI_ParseFile(uFile, "LoadUser_user", .bExtra = true, .extra = playerid);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                    SetPVarInt(playerid, "Logged", 1);
                }
                else
                {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have     entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                return 1;
                }
           
            }
        }

Nope i can still log in with any password.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)