News:

Wondering if this will always be free?  See why free is better.

Main Menu

Login Class Method

Started by Greg23, May 26, 2008, 07:05:25 PM

Previous topic - Next topic

Greg23

For an integration with my blog system, I'd like to know if there is some service URL hxxp:example.com/auth [nonactive] and authenfication method auth.login I could call via XML-RPC (for instance).

Let's see what I would like to use :
class myDcAuth extends dcAuth
{
protected $allow_pass_change = false;

public function checkUser($user_id, $pwd=null, $user_key=null)
{
if ($pwd == '') {
return parent::checkUser($user_id,null,$user_key);
}

try
{
$this->con->begin();
$cur = $this->con->openCursor($this->user_table);

$client = new xmlrpcClient('http://example.com/auth');
$info = $client->query('auth.login',$user_id,$pwd);

$cur->user_pwd = $pwd;

if ($this->core->userExists($user_id))
{
$this->sudo(array($this->core,'updUser'),$user_id,$cur);
$this->con->commit();
}

else
{
$cur->user_id = $info['login'];
$cur->user_email = $info['email'];
$cur->user_name = $info['name'];
$cur->user_firstname = $info['firstname'];
$cur->user_lang = $info['lang'] ? $info['lang'] : 'en';
$cur->user_tz = 'Europe/Paris';
$cur->user_default_blog = 'default';

$this->sudo(array($this->core,'addUser'),$cur);
$this->sudo(array($this->core,'setUserBlogPermissions'),
$user_id,'default',array('usage'=>true));
$this->con->commit();
}

return parent::checkUser($user_id,$pwd);
}
catch (Exception $e)
{
$this->con->rollback();
return false;
}
}
}


thanks for replies :)

PS: I am discovering the soft, I love it  ;D

Advertisement: