Change password mysql
#1

This change pass cmd doesn't work:

Код:
CMD:changepass(playerid, params[])
{
	new pass[30];
    if (sscanf(params, "s[30]", pass))
	{
		return SendClientMessage(playerid, COLOR_THISTLE, "USAGE: /changepass [newpass]");
	}

	if (strlen(pass) < 4 || strlen(pass) > MAX_PLAYER_NAME)
	{
		return SendClientMessage(playerid, COLOR_TOMATO, "* Invalid password length, must be between 4-24 characters.");
	}

	new hash[128];
	SHA256_PassHash(pass, "aafGEsq13", hash, sizeof(hash));
	new handle = SQL::Open(SQL::READ, "players", "p_password", UserInfo[playerid][p_password]);
    SQL::ReadInt(handle, "p_password", UserInfo[playerid][p_password]);
                
	SHA256_PassHash(pass, "", UserInfo[playerid][p_password], 64);

	PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);

	SendClientMessage(playerid, COLOR_GREEN, "You have successfully changed your account password.");
	GameTextForPlayer(playerid, "~w~Password changed", 5000, 3);
	return 1;
}
Reply
#2

Obviously, since there's no WRITE operation. First you open a READ handle for no reason at all. Then you attempt to read a string with a function designed for integers, also for no reason. Then finally you do something weird with that second PassHash, possibly in an attempt to store the new password in the array. Should use strcpy for that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)