在阅读Zend文档和一些帖子后,我无法弄清楚如何让我的用户角色脱离用户表。Zend_ACL如何获得角色?
此刻,我在AuthController使用Zend_Auth的是这样的:
// Set authentication adapter and map ID and Cre.
// only admins could log in here
$adapter = new Zend_Auth_Adapter_DbTable($this->db,
'customers',
'login',
'password',
'MD5(?)');
$adapter->setIdentity($form->getValue('username'))
->setCredential($form->getValue('password'));
// Check if authentification is right
$result = Zend_Auth::getInstance()->authenticate($adapter);
if (!$result->isValid()) {
..
}
后来通过根据结果的Zend_Controller_Plugin和路由检查:
if (Zend_Auth::getInstance()->hasIdentity()) {
return;
} elseif ($request->getControllerName() == 'auth' || $request->getControllerName() == 'index') {
return;
} else {
$request->setControllerName('index');
$request->setActionName('index');
return;
}
现在我想改变路线取决于用户的滚动。如果用户是管理员,他可以访问AdminController,但是如何从我的用户表中获取角色?该列称为类型,它包含一个字符串女巫表示角色。
我希望你能帮助我。
问候,
-lony