Save the player password
#1

Greetings,

I've created a command called /changepass,

This should save the hashed password to the database however, it's not hashing it,
Its saving the raw password, This is not what i want, is there anyone able to help me to fix this issue?

current code :

Код:
CMD:changepass(playerid, params[])
{
	new 
		hash[129],
		oldpass[24], 
		newpass[24],
		c_newpass[24],
		playername[24]
	;

	if(sscanf(params,"s[24]s[24]s[24]", oldpass, newpass, c_newpass)) 
		return SendClientMessage(playerid,COLOR_WHITE,"{ff0000}[Server]:{ffffff} /changepass [currentpass] [newpass] [newpass]");

	if (strlen(newpass) > MAX_PLAYER_PASSWORD) 
		return SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Server]:{ffffff} password can maximal be 16 characters.");
	
	if (strlen(newpass) < MIN_PLAYER_PASSWORD) 
		return SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Server]:{ffffff} password needs to be atleast 6 characters.");
	WP_Hash(hash, sizeof (hash), oldpass);
	if ( !strcmp(hash, pData[playerid][Password], false) ) // The NEW hash does match the old (saved) one
	{
		if ( !strcmp(newpass, c_newpass, false) ) // match
		{
			SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Server]:{ffffff} Password changed!");
			GetPlayerName(playerid, playername, sizeof(playername));
			new query[512];
       		mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Password`='%s' WHERE `ID`=%d", hash, pData[playerid][ID]);
        	mysql_tquery(mysql, query, "", "");
			strmid(pData[playerid][Password], newpass, 0, strlen(newpass), sizeof(newpass));
			SavePlayerData(playerid);
		}
		else SendClientMessage(playerid, -1, "{ff0000}[Server]:{ffffff} Your new passwords do not match."); 
	}
	else SendClientMessage(playerid, -1, "{ff0000}[Server]:{ffffff} Your current password does not match.");

	return 1;
}
Reply


Messages In This Thread
Save the player password - by yvoms - 25.07.2016, 12:59
Re: Save the player password - by Threshold - 25.07.2016, 13:09
Re: Save the player password - by yvoms - 25.07.2016, 13:10
Re: Save the player password - by yvoms - 25.07.2016, 14:55
Re: Save the player password - by Threshold - 25.07.2016, 16:17
Re: Save the player password - by yvoms - 25.07.2016, 17:11
Re: Save the player password - by Threshold - 25.07.2016, 17:53
Re: Save the player password - by yvoms - 25.07.2016, 20:34
Re: Save the player password - by Threshold - 26.07.2016, 03:48
Re: Save the player password - by yvoms - 26.07.2016, 09:51

Forum Jump:


Users browsing this thread: 1 Guest(s)