Jump to content


Photo

How to add a user/password authentication as XML-RPC method

xmlrpc wordpress user authentication

  • Please log in to reply
1 reply to this topic

#1 realeez

realeez

    Member

  • Members
  • PipPip
  • 12 posts

Posted 25 September 2013 - 11:56 AM

Dear friends,
I am using the XML-RPC Server to implement a simple login authentication as a web service . So I wrote a function in wp-includes\class-wp-xmlrpc-server.php like

function web_auth($host, $db, $dbuser, $dbpass, $username, $password)
{
$dbhandle = mysql_connect($host, $dbuser, $dbpass) or die("Unable to connect to MySQL");
$selected = mysql_select_db($db,$dbhandle) or die("Could not select database");
//$md5_password = md5($password);
$md5_password = wp_hash_password($password);
$result = mysql_query("SELECT count(*) AS total FROM wp_users WHERE user_login='$username' AND user_pass='$md5_password' AND user_status=0");
$data=mysql_fetch_assoc($result);
//echo "SELECT count(*) AS total FROM wp_users WHERE user_login='$username' AND user_pass='$md5_password' AND user_status=0";
//die($data['total']);
if($data['total'] == 1)
{
return true;
}
return false;
}

But the password hash mechanism is not make things proper. Please help me to find the exact password in line

$md5_password = wp_hash_password($password);

Waiting your fast reply

Thanks,
Anes



#2 mac_gyver

mac_gyver

    Advanced Member

  • Moderators
  • 1,895 posts

Posted 25 September 2013 - 12:22 PM

the wp_hash_password() function is used to initially generate the hash of the password. this is the value that is stored in the database table.

 

to compare if an entered password matches, you must retrieve the stored password hash from the database table and use the

$wp_hasher->CheckPassword() method. this is covered in the wordpress wp_hash_password() documentation - http://codex.wordpre...p_hash_password


multi-purpose programming fool and resident naysayer [We try not be negative in replies, but telling someone what they're doing wrong, while staying politically correct, isn't always going to happen.]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com