SA-MP Forums Archive
My login system is accepting any password. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: My login system is accepting any password. (/showthread.php?tid=451268)



My login system is accepting any password. - xXitsgodzillaXx - 16.07.2013

Okay for some reason my login system is accepting any password, I've been looking around for about 2 days. I can not figure this one out. So here is my code:

pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
        if (!response) return Kick(playerid);
        if(response)
        {
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
            new INI:File = INI_Open(UserPath(playerid));
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            INI_SetTag(File,"data");
            INI_WriteString(File, "Password", hashpass);
            INI_WriteInt(File,"Cash",0);
            INI_WriteInt(File,"Admin",0);
            INI_WriteInt(File,"Kills",0);
            INI_WriteInt(File,"Deaths",0);
            INI_WriteInt(File,"Score",0);
            INI_WriteInt(File,"Banned",0);
            INI_WriteInt(File,"Muted",0);
            INI_WriteInt(File,"Regular",0);
            INI_Close(File);
            ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Success!","Great! You have succesfully created your account!","Ok","");
        }
    }

    if(dialogid == DIALOG_LOGIN)
    {
        if (!response) return Kick(playerid);
        if(response)
        {
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
            if(!strcmp(hashpass,SInfo[playerid][pPass]))
            {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                GivePlayerMoney(playerid, SInfo[playerid][pCash]);
                SetPlayerScore(playerid, SInfo[playerid][pScore]);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","You have entered an incorrect password.\nPlease retype your password below to login.","Login","Quit");
            }
            return 1;
        }
    }
    return 0;
}
I don't get any errors at all. So if someone could help me it would be greatly appreciated!


Re: My login system is accepting any password. - ReVo_ - 16.07.2013

Make sure your strings are not empty. (Use printf or SendClientMessage)

https://sampwiki.blast.hk/wiki/Strcmp

Important Note: This function also returns 0 if either string is empty.


Re: My login system is accepting any password. - PaulDinam - 16.07.2013

Where are you loading the player stats from?
SInfo[playerid][pPass]


Re: My login system is accepting any password. - xXitsgodzillaXx - 16.07.2013

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
Where are you loading the player stats from?
SInfo[playerid][pPass]
pawn Код:
enum PInfo
{
    Name[60],
    pPass[129],
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pScore,
    pOnDuty,
    pBan,
    pMute,
    pRegular
};
new SInfo[MAX_PLAYERS][PInfo];
EDIT: so I tried this and its still doing the same thing.

pawn Код:
if(dialogid == DIALOG_LOGIN)
    {
        if (!response) return Kick(playerid);
        if(response)
        {
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(!strcmp(hashpass,SInfo[playerid][pPass],true,128))
            {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                GivePlayerMoney(playerid, SInfo[playerid][pCash]);
                SetPlayerScore(playerid, SInfo[playerid][pScore]);
                SendClientMessage(playerid,COLOR_KS,"Welcome back! You have successfully logged in");
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","You have entered an incorrect password.\nPlease retype your password below to login.","Login","Quit");
            }
        }
        return 1;
    }
    return 0;
}



Re: My login system is accepting any password. - Vince - 16.07.2013

Read what's being said, instead of selectively ignoring certain posts.

Quote:
Originally Posted by ReVo_
Посмотреть сообщение
Make sure your strings are not empty. (Use printf or SendClientMessage)



Re: My login system is accepting any password. - xXitsgodzillaXx - 16.07.2013

Quote:
Originally Posted by Vince
Посмотреть сообщение
Read what's being said, instead of selectively ignoring certain posts.
Well If you took a look at my changes maybe you would understand that I did look at everything that was said.


Re: My login system is accepting any password. - tyler12 - 16.07.2013

You're loading the file after the player has entered a password.

Put INI_ParseFile() under OnPlayerConnect if the player is registered.


Re: My login system is accepting any password. - ThePhenix - 16.07.2013

PHP код:
if(dialogid == DIALOG_LOGIN)
    {
        if (!
response) return Kick(playerid);
        if(
response)
        {
            new 
hashpass[129];
            
WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(
hashpass == SInfo[playerid][pPass]))
            {
                
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                
GivePlayerMoney(playeridSInfo[playerid][pCash]);
                
SetPlayerScore(playeridSInfo[playerid][pScore]);
                
SendClientMessage(playerid,COLOR_KS,"Welcome back! You have successfully logged in");
            }
            else
            {
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD,"Login","You have entered an incorrect password.\nPlease retype your password below to login.","Login","Quit");
            }
        }
        return 
1;
    }
    return 
0;




Re: My login system is accepting any password. - xXitsgodzillaXx - 16.07.2013

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
PHP код:
if(dialogid == DIALOG_LOGIN)
    {
        if (!
response) return Kick(playerid);
        if(
response)
        {
            new 
hashpass[129];
            
WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(
hashpass == SInfo[playerid][pPass]))
            {
                
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                
GivePlayerMoney(playeridSInfo[playerid][pCash]);
                
SetPlayerScore(playeridSInfo[playerid][pScore]);
                
SendClientMessage(playerid,COLOR_KS,"Welcome back! You have successfully logged in");
            }
            else
            {
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD,"Login","You have entered an incorrect password.\nPlease retype your password below to login.","Login","Quit");
            }
        }
        return 
1;
    }
    return 
0;

Код:
C:\Documents and Settings\Owner\Desktop\Jaysens crap\DDPUSI TDM\gamemodes\DDPTDM.pwn(901) : error 033: array must be indexed (variable "hashpass")
C:\Documents and Settings\Owner\Desktop\Jaysens crap\DDPUSI TDM\gamemodes\DDPTDM.pwn(901) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Owner\Desktop\Jaysens crap\DDPUSI TDM\gamemodes\DDPTDM.pwn(908) : error 029: invalid expression, assumed zero



Re: My login system is accepting any password. - gtakillerIV - 16.07.2013

Код:
if(hashpass == SInfo[playerid][pPass]))
Use strcmp to compare strings.