Login script allows any password
#1

My register code:

Код:
case DIALOG_REGISTER:
        {
            if (!response) return 1;
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"{FF21E1}Register","{F5ED05}Type your password below to register an account.\n{FA1111}That password is invalid","Register","Cancel");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteString(File,"Password",inputtext);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Vip",0);
                INI_WriteInt(File,"Muted",0);
                INI_WriteInt(File,"Ban",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"Pet",0);
                INI_Close(File);
                SendClientMessage(playerid, COLOR_GREEN, "Your stats will now be saved! You have been logged in automatically.");
            }
        }
Login code:

Код:
case DIALOG_LOGIN:
        {
            if (!response) return Kick (playerid);
            if(response) 
            {
                if(strcmp(inputtext, PlayerInfo[playerid][pPass], false))
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SendClientMessage(playerid, COLOR_GREEN, "You have been logged in.");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{FF21E1}Login","{F5ED05}Type your password below to login.\n{FA1111}Incorrect password!","Login","Quit server");
                }
                return 1;
            }
        }
When i register with the password 666 and i login with the password 777 it allows me to login
Reply
#2

What do you need dude?:
Reply
#3

It would be good, If you explain us your problem.
Reply
#4

Topic title: "Login script allows any password"

Read before posting dude.


Your problem is on the strcmp line. See information about the function here: https://sampwiki.blast.hk/wiki/strcmp

pawn Код:
if(strcmp(inputtext, PlayerInfo[playerid][pPass], false))
strcmp returns 0 when the strings match. So, you can use this:

pawn Код:
if(!strcmp(inputtext, PlayerInfo[playerid][pPass], false))
Also, HASH YOUR PASSWORDS.
Reply
#5

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Topic title: "Login script allows any password"

Read before posting dude.


Your problem is on the strcmp line. See information about the function here: https://sampwiki.blast.hk/wiki/strcmp

pawn Код:
if(strcmp(inputtext, PlayerInfo[playerid][pPass], false))
strcmp returns 0 when the strings match. So, you can use this:

pawn Код:
if(!strcmp(inputtext, PlayerInfo[playerid][pPass], false))
Also, HASH YOUR PASSWORDS.
Thanks and yes I do hash my passwords but I was trying to fix the problem myself and I tried it with removing the udb hash
Reply
#6

You should check if the input is null too.
Reply
#7

Quote:
Originally Posted by ryansheilds
Посмотреть сообщение
You should check if the input is null too.
Yes I included that aswell
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)