Register System issues.
#1

Hello.

So I'm having some issues with my registration system. When I register my account, it writes just fine. But upon trying to login - I can login with ANY password. I've also tried to modify it in various ways but issues still occur, such as me not being able to login at all.

Here's my current code. I was following a tutorial, attempting to learn more about the way yini works. If more code is needed, let me know.

pawn Код:
if(dialogid == REGISTER_LOGIN)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(!strcmp(hashpass, pInfo[playerid][pPass], false))
            {
                INI_ParseFile(Path(playerid),"LoadAccount_%s",.bExtra = true, .extra = playerid);
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
            }
            else
            {
                ShowPlayerDialog(playerid,REGISTER_LOGIN,DIALOG_STYLE_INPUT,"Login","Incorrect Password.","Login","Quit");
                return 1;
            }
         }
    }
Reply
#2

pawn Код:
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Reply
#3

Make sure you load the player's password into pInfo before you compare the strings because strcmp will return 0 (aka say the strings match) if one of the strings is empty. So if you don't load the password before you compare them then pInfo[playerid][pPass] will be empty and it will accept any password.
Reply
#4

This works perfectly for me.

pawn Код:
new HashPass[128];
WP_Hash(HashPass, sizeof(HashPass), inputtext);
if(!strcmp(HashPass, pInfo[playerid][pPass])) {
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
} else {
    ShowPlayerDialog(playerid,REGISTER_LOGIN,DIALOG_STYLE_INPUT,"Login","Incorrect Password.","Login","Quit");
    return 1;
}
Reply
#5

Quote:
Originally Posted by Chenko
Посмотреть сообщение
Make sure you load the player's password into pInfo before you compare the strings because strcmp will return 0 (aka say the strings match) if one of the strings is empty. So if you don't load the password before you compare them then pInfo[playerid][pPass] will be empty and it will accept any password.
Not too sure what you mean. Could you show an example? This is my enum:

pawn Код:
enum PlayerInfo
{
    pPass[128],
    pKills,
    pDeaths,
    pVip,
    pAdmin
}
Reply
#6

Quote:
Originally Posted by mrkiller90
Посмотреть сообщение
pawn Код:
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
He is not even using that method to hash the passwords.
Reply
#7

Quote:
Originally Posted by JacobEdwards
Посмотреть сообщение
He is not even using that method to hash the passwords.
That's why I ignored his post. I'm using whirlpool, not udbhash stock.
Reply
#8

Quote:
Originally Posted by JacobEdwards
Посмотреть сообщение
This works perfectly for me.

pawn Код:
new HashPass[128];
WP_Hash(HashPass, sizeof(HashPass), inputtext);
if(!strcmp(HashPass, pInfo[playerid][pPass])) {
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
} else {
    ShowPlayerDialog(playerid,REGISTER_LOGIN,DIALOG_STYLE_INPUT,"Login","Incorrect Password.","Login","Quit");
    return 1;
}
I'm still able to login with any password upon registering.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == REGISTER_REGISTER)
    {
        if(!response)
        {
            Kick(playerid);
        }
        if(response)
        {
            if(!strlen(inputtext))
            {
                SCM(playerid,COLOR_RED, "You must enter a password to register a account.");
                ShowPlayerDialog(playerid, REGISTER_REGISTER, DIALOG_STYLE_INPUT, "Please register a account.", "Register", "Enter", "Leave");
                return 1;
            }
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            new INI:file = INI_Open(Path(playerid));
            INI_SetTag(file, "Player Data");
            INI_WriteString(file,"Password",hashpass);
            INI_WriteInt(file, "Kills", 0);
            INI_WriteInt(file, "Deaths", 0);
            INI_WriteInt(file, "Vip", 0);
            INI_WriteInt(file, "Admin", 0);
            INI_Close(file);
            new string[128];
            format(string,sizeof(string), "You've registered at Highschool Roleplay with the password %s", inputtext);
            SCM(playerid,COLOR_GREEN, string);
            ShowPlayerDialog(playerid,REGISTER_LOGIN,DIALOG_STYLE_INPUT,"Login","Enter your password to login.","Login","Quit");
        }
    }
    if(dialogid == REGISTER_LOGIN)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(!strcmp(hashpass, pInfo[playerid][pPass]))
            {
                INI_ParseFile(Path(playerid),"LoadAccount_%s",.bExtra = true, .extra = playerid);
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
            }
            else
            {
                ShowPlayerDialog(playerid,REGISTER_LOGIN,DIALOG_STYLE_INPUT,"Login","Incorrect Password.","Login","Quit");
                return 1;
            }
         }
    }
    return 1;
}
Reply
#9

did you tried changing enum pPass[128] to pPass[129] ? if not then try
Reply
#10

I've tried everything, yes. Even tried making the password a integer instead of a string. I've also tried using udb_has instead of whirlpool. Still nothing. I really dont want to copy and paste and would rather learn my mistakes. I hand-wrote this one myself, minus the udb hash stock and a few minor queries.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)