I want to have multiple login with in single zend application.
I have five sections A,B,C,D,E and four type of users (P,Q,R,S) including anonymous user.These section have sub sections. Section A,B,C required login to access them. Section D and E can be accessed by开发者_如何转开发 all type of users but there are some action that can be followed by specific type of users.
P can only login to sec A, Q can login to sec B and R can login to sec C.
Can you please suggest what directory structure I should use and how should I implement multiple login.
Thanks
the directory structure has nothing to do with the access rights. your whole application could be a single controller and be capable of your roles and rights concept but would not be nice code tbh.
if you don't wanna use Zend_Acl (why not?) you could solve it by implementing a simple concept like the following:
create an application module for each of your "sections" including a PublicController in each application which will be accessible by anyone later. then you should implement a front controller plugin which could look like the folloing
public function preDispatch()
{
$identity = Zend_Auth::getInstance()->getIdentity();
$module = $this->getRequest()->getModuleName();
$controller = $this->getRequest()->getControllerName();
if($controller == 'public') {
return;
}
switch ($identity->role) {
case 'A':
if ($module != 'P') {
$this->myNotAuthorized();
}
break;
// cases for other roles/modules
}
}
You are likely looking for a Role based Access Control List.
Zend Framework offers this through Zend_Acl
.
Also see:
- Devzone: Zend_Acl / Zend_Auth example scenario
- Top Site about Zend_Acl
You can also do it a simple way by not to implement Zend_ACL if you don't want it.
Use session variables and check those on module access.
精彩评论