之前我曾涉足过Modx,但这是我第一次尝试使用插件。
我编写了以下插件来针对第三方数据库对用户进行身份验证。系统事件OnWebAuthentication已启用。
if ($modx->event->name == 'OnWebAuthentication') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'{urlhere}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
curl_close($ch);
if($output == '1')
{
$modx->event->output(true);
}else{
$modx->event->output(false);
}
}
答案 0 :(得分:0)
你没有解释你想要做什么,所以我将解释事件触发器。
正如您在login.class.php中所看到的,当用户通过e.i身份验证时会触发此事件。登录。但是,如果isMgr
为真,则不会触发此事件。 isMgr
定义为($this->loginContext == 'mgr')
。这意味着如果用户登录上下文mgr(例如登录/manager
),则不会触发事件,但OnManagerAuthentication
将会触发。
如果您想要登录用户,最简单的方法是使用Login extra。维基中有几个examples。您还可以指定他们应该登录的上下文。