password help (y_ini + Whirpool) +REP
#1

hello, when i save my password with y_ini and using wp for hashing pass, ok it's saves the hash but when i login, when i login with the incorrect password, it logins, same with correct password, logins, but the problem is why incorrect password logins?
code:
pawn Код:
// this is the loading code
forward LoadUser_Data(playerid, name[], value[]);
public LoadUser_Data(playerid, name[], value[])
{
    INI_String("Password", PlayerInfo[playerid][Password], 129);
    INI_Int("Score", PlayerInfo[playerid][Score]);
    INI_Int("Deaths", PlayerInfo[playerid][Deaths]);
    INI_Int("Level", PlayerInfo[playerid][Level]);
    INI_Int("Kills", PlayerInfo[playerid][Kills]);
    INI_Int("Cash", PlayerInfo[playerid][Cash]);
    INI_Int("Zones", PlayerInfo[playerid][Zones]);
    return 1;
}
other
pawn Код:
// At onplayerdisconnect
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",PlayerInfo[playerid][Cash] = GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][Level]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][Kills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][Deaths]);
    INI_WriteInt(File, "Score", PlayerInfo[playerid][Score] = GetPlayerScore(playerid));
    INI_WriteInt(File, "Zones", PlayerInfo[playerid][Zones]);
    INI_Close(File);
dialog responses
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response)
            {
                SendClientMessage(playerid, RED, "[SYSTEM] okay, You may register Later! use /register...");
                ShowPlayerDialog(playerid, DIALOG_TEAMS, DIALOG_STYLE_LIST, "Select a Team", "{0019FF}United States Of America\n {FFFA00}Asian Army", "Select", "Cancel");
            }
            if(response)
            {
                if(!strlen(inputtext)) return  ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD," Register |", "You may register now if you wish", "OK", "Later");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File, "data");
                new hashpass[129];
                WP_Hash(hashpass, sizeof(hashpass), inputtext);
                INI_WriteString(File, "Password", hashpass);
                INI_WriteInt(File, "Level", PlayerInfo[playerid][Level]);
                INI_WriteInt(File, "Score", PlayerInfo[playerid][Score] = GetPlayerScore(playerid));
                INI_WriteInt(File, "Cash", PlayerInfo[playerid][Cash] = GetPlayerMoney(playerid));
                INI_WriteInt(File, "Kills", PlayerInfo[playerid][Kills]);
            INI_WriteInt(File, "Deaths", PlayerInfo[playerid][Deaths]);
            INI_WriteInt(File, "Zones", PlayerInfo[playerid][Zones]);
            INI_Close(File);
            SendClientMessage(playerid, GREEN, "You have been sucessfully in registering!");
            ShowPlayerDialog(playerid, DIALOG_TEAMS, DIALOG_STYLE_LIST, "Select a Team", "                                            {0019FF}United States Of America\n {FFFA00}Asian Army", "Select", "Cancel");
                return 1;

               
            }
                           
        }
login
pawn Код:
case DIALOG_LOGIN:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                new hashpass[129];
                WP_Hash(hashpass, sizeof(hashpass), inputtext);
                if(!strcmp(hashpass, PlayerInfo[playerid][Password], false))
                {
                    INI_ParseFile(UserPath(playerid), "LoadData_%s", .bExtra = true, .extra = playerid);
                    SendClientMessage(playerid, GREEN, "    - - - - -   USER STATS INFORMATION - - - - ");
                    SendClientMessage(playerid, GREEN, " - - - - SYSTEM HAS LOADED  SUCESSFULLY- - - - - ");
                    ShowPlayerDialog(playerid, DIALOG_TEAMS, DIALOG_STYLE_LIST, "Select a Team", "{0019FF}United States Of America\n {FFFA00}Asian Army", "Select", "Cancel");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "This account is registered please login", "OK", "Cancel");
                    SendClientMessage(playerid, RED, "Wrong Password");
                    return 1;
                }
               
            }
        }
Thanks..
Reply
#2

where did you load your password? My system loads the password when the login dialog appears. Example:
pawn Код:
if(response)
        {
            WP_Hash(password, sizeof(password), inputtext);
            format(string, sizeof(string), "SELECT * FROM `USERS` WHERE `NAME`='%s' AND `PASSWORD`='%s'", DB_Escape(RPN(playerid)), DB_Escape(password)); // this should be your loading code
            result = db_query(UserDatabase, string);
            if(db_num_rows(result) > 0) // this is your strcmp
            {
Reply
#3

EDIT: sorry, it loads at on player connect and under the same loading code, i show the dialog
Reply
#4

bump, please help guys :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)