Zend: Strategy for admin login -


itemprop = "text">

The user belongs to the guest, and he reaches when / admin / I think the redirect For / admin / login and when a user is in the default module and accesses a resource in which it does not have access, then I will call it at / error I want to redirect.

Let's assume that / admin is a module, how can I complete it? Here I have so far:?

  & lt; Php class KG_Controller_Plugin_Acl extends {Zend_Controller_Plugin_Abstract {public function __construct (Zend_Acl $ ACL, Zend_Auth $ certification) $ this- & gt; _acl = $ ACL; $ This- & gt; _auth = $ auth; } Public Function preDispatch (Zend_Controller_Request_Abstract $ request) {$ auth = $ this- & gt; _auth; If ($ auth-> isiDentity ()) {$ identification = $ auth-> GetIdentity (); $ Roll = stroller ($ identity-> role); } And {$ role = 'guest'; } $ Controller = $ request-> Controller; $ Action = $ request- & gt; Action; $ Modules = $ request-> Module; If ($ module == 'admin') {if ($ this->; _acl- & gt; isAllowed ($ role, $ controller, $ action)) {if ($ role == 'guest') {$ Request & gt; SetControllerName ('index'); $ Request & gt; SetActionName ('index'); } And ($ request-> setControllerName ('login'); $ request & gt; setActionName ('index');}}} Else {if ($ this->! _acl- & gt; isAllowed ($ {$ Role == 'guest'} {$ request & gt; setControllerName ('user'); $ request & gt; setActionName ('login');} and {$ Request- & gt; setControllerName ('Error'); $ request & gt; setActionName ('noauth');}}}}}  

and to define roles:

  & lt; php class Model_Acl extends Zend_Acl {Public Function __construct () {$ this- & gt; AddRole (New Zend_Acl_Role ('Guest')); $ This-> Adrol (New Zend_Acl_Role ('U $ The-> Adrool (New Zend_Acl_Role ('Admin'), 'User'); $ This- & gt; Add (New Zend_Acl_Resource ('index'); $ This- Add (New Zend_Acl_Resource ('Error')); $ This- & gt; Add (New Zend_Acl_Resource ('admin')); $ This- & gt; Add (New Zend_Acl_Resource ('Page')); $ This - & gt; Add (New Zend_Acl_Resource ('news')); $ This- & gt; Add (New Zend_Acl_Resource ('mvc: user_signin')); $ This- & gt; Add (New Zend_Acl_Resource ('mvc: user_signout')); $ This- & gt; Add (New Zend_Acl_Resource ('menu')); $ This- & gt; Add (New Zend_Acl_Resource ('menuitem')); $ This- & gt; Add (New Zend_Acl_Resource ('Users')); $ This- & gt; Add (New Zend_Acl_Resource ('Search')); $ This- & gt; Add (New Zend_Acl_Resource ('feed')); $ This- & gt; Add (New Zend_Acl_Resource ('bug')); $ This- & gt; Allow (empty, array ('index', 'error')); $ This- & gt; Allow ('guest', 'page', array ('index', 'open')); $ This- & gt; Allow ('guest', 'menu', array ('render')); $ This- & gt; Allow ('guest', 'user', array ('login')); $ This- & gt; Allow ('guest', 'search', array ('index', 'search')); $ This- & gt; Allow ('guest', 'feed'); $ This- & gt; Allow ('guest', 'news'); $ This- & gt; Allow ('Guest', New Zend_Acl_Resource ('mvc: user_signin'), 'Navigate'); $ This- & gt; Reject ('Guest', New Zend_Acl_Resource ('mvc: user_signout', 'Navigate'); $ This- & gt; Allow ('Users', New Zend_Acl_Resource ('mvc: user_signout'), 'Navigate'); $ This- & gt; Allow ('user', 'page', array ('list', 'create', 'edit', 'delete')); $ This- & gt; Allow ('Admin', blank); }}  

To redirect it to admin login controller, - & gt; Trying to reject ('guest', 'admin') . To do this, would appreciate the advice about a decent solution.

After

I ended up optimizing my code that defines new resources and just the controller's Rather than using, I have followed the resources in the "module.controller" format, then I have done so well and so far.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -