Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://rads.stackoverflow.com/amzn/click/1430218797" rel="nofollow noreferrer">Pro Zend Framework Techniques</a>, Chapter 8 has a nice treatment of this. Most of his approach is quite similar to what I use, with the exception of the preDispatch method. When authenticating I have preDispatch redirect instead of silently dispatching to another controller. I also preserve the Url that was requested for the use of the login action.</p> <pre> class SitePluginAuth extends Zend_Controller_Plugin_Abstract { private $_auth; private $_acl; private $_noauthPath = '/account/log-in/'; private $_noacl = array('module' => 'default', 'controller' => 'error', 'action' => 'denied'); public function __construct($auth, $acl) { $this->_auth = $auth; $this->_acl = $acl; } public function preDispatch($request) { $resource = $request->controller; if (!$this->_acl->has($resource)) return; $controller = $request->controller; $action = $request->action; $module = $request->module; if ($this->_auth->hasIdentity()) { $identity = $this->_auth->getIdentity(); $role = 'member'; } else { $role = 'guest'; } /* * Remember to URL encode the parameter value. Also, when you are processing the value of the * redirect URL, make sure that it is a URL on your site or a relative URL to avoid any security * attacks like a phishing scheme. Otherwise, a third party can target your site's login page and * then redirect back to their site and might have access to the user's secured session. * * The reason I don't use the session to store the URL, is that search engine spiders can end up * creating sessions as they hit links on your site that are secured and require login. Since they * have no credentials, the session is created only to timeout 30 minutes later. */ if (!$this->_acl->isAllowed($role, $resource, $action)) { if (!$this->_auth->hasIdentity()) { $requestedUrl = substr($request->getRequestUri(), strlen($request->getBaseUrl())); // relative url $loginUrl = $this->_noauthPath.'?requestedUrl='.urlencode($requestedUrl); $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoUrl($loginUrl); } else { $request->setModuleName($this->_noacl['module']); $request->setControllerName($this->_noacl['controller']); $request->setActionName($this->_noacl['action']); } } } } </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload