Password help! [Rep+]
#1

Hello guys,

I've used this tutorial : https://sampforum.blast.hk/showthread.php?tid=273088
To make myself a login/register system using y_ini. Everything work's fine. But the biggest problem is no matter password you enter. You still can access anyone's account? Ex: I entered pass as 12345 on Registration. But i can login with any number? Idk why. Im using udb_hash to hash password's?

Is there anyone who can correct my code's? or can Save the string as it is entered into the ini file for the user. And correct the Login Dialog response for me! I hope you understand!

- BMiaa

-Posted my code below-

pawn Код:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext))
                {
                    new regstring[128];
                    format(regstring,sizeof(regstring),"Country Wars:WWIII\nPlease register your account by typing you password below");
                    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Register",regstring,"Register","Exit");
                    SendClientMessage(playerid, COLOR_YELLOW, "Your password can not be left blank. Please input password to register your account & proceed.");

                }
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Key",udb_hash(inputtext));
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Banned",0);
                INI_WriteInt(File,"DonateRank",0);
                INI_WriteInt(File,"Warnings",0);
                INI_WriteInt(File,"Jail",0);
                INI_WriteInt(File,"JailTime",0);
                INI_WriteInt(File,"Cash", 0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Muted",0);
                INI_WriteInt(File,"Hide",0);
                INI_WriteInt(File,"Spree",0);
                INI_WriteInt(File,"DuelWon",0);
                INI_WriteInt(File,"DuelLost",0);
                INI_WriteInt(File,"Clan",0);
                INI_WriteInt(File,"ClanRank",0);
                INI_Close(File);
            }
        }
        case DIALOG_CHANGEPASS:
        {
            new INI:File = INI_Open(UserPath(playerid));
            INI_SetTag(File,"data");
            INI_WriteInt(File,"Key",udb_hash(inputtext));
            INI_Close(File);
            new str[128];
            format(str, sizeof(str), "[CW:WW3] Your password has been changed to %s",inputtext);
            SendClientMessage(playerid, COLOR_RED, str);
        }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pKey])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    //JustLogin[playerid] = 1;
                }
                else
                {
                    new loginstring[256];
                    SendClientMessage(playerid, COLOR_YELLOW, "[CW:WW3] That name is registered, please wait to login");
                    SendClientMessage(playerid, COLOR_WHITE, "HINT: You can now login by typing your password below");
                    format(loginstring,sizeof(loginstring),"Country Wars:WWIII\nThat name is registered. please enter your password below");
                    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login",loginstring,"Login","Exit");
                }
                return 1;
            }
        }
Reply
#2

Is there any way to save the hashed password as the same string as it is entered by the user! I dont care about the privacy first of all :S! Please someone help
Reply
#3

I made a mistake like this before, and I fixed it. Show me where you're writing the data under OnPlayerDisconnect or wherever your saving function is.

EDIT:

Try changing this line
pawn Код:
if(udb_hash(inputtext) == PlayerInfo[playerid][pKey])
pawn Код:
if(udb_hash(inputtext) != PlayerInfo[playerid][pKey])
{
    return Kick(playerid);
}
EDIT: (Again)

I don't really agree with your login part. You can try looking at mine, which works %100. Can't explain it though it's like 2AM.
pawn Код:
case DIALOG_LOGIN: //LOGIN
        {
            if(!response) return Kick(playerid);
            if(udb_hash(inputtext) != pInfo[playerid][pPass])
            {
                SendClientMessage(playerid,COLOR_LIGHTGRAY,"Incorrect password.");
                Kick(playerid);
            }
            if(response)
            {
                if(udb_hash(inputtext) == pInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid,pInfo[playerid][pCash]);
                    SetSpawnInfo(playerid,0,299,2102.6221,-104.2249,2.2702,88.673,0,0,0,0,0,0);
                    SpawnPlayer(playerid);
                }
                return 1;
            }
        }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)