You can do it wherever you'd like - as long as you've set the 'return' request parameter before you change the module/controller/action :-)
--
Bradley Holt
bradley.holt@foundline.com
On Mon, Sep 29, 2008 at 10:52 AM, Jigal sanders <jigalroecha@gmail.com> wrote:
I think I don'[t agree with you since it's a fall through method.
I will post the whole method and you will see my comments:
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$frontController = Zend_Controller_Front::getInstance();
$controller = $request->getControllerName();
$action = $request->getActionName();
$module = $request->getModuleName();
//Zend_Debug::dump($this->_auth->hasIdentity(), 'de',true);//If my session is due. Or I am not logged in, i get here. So that's why i think, i need to do something here.
if ($this->_auth->hasIdentity()) {
$role = $this->_auth->getIdentity()->role;
} else {$isDispatchable = $frontController->getDispatcher()->isDispatchable($request);
$role = 'guest';
}
$resource = $request->controller;
if (!$this->_acl->has($resource)) {
$resource = null;
}
if ($isDispatchable && !$this->_acl->isAllowed($role, $resource, $action)) {
if (!$this->_auth->hasIdentity()) {
// Not logged in, send to login page
$module = $this->_noauth['module'];
$controller = $this->_noauth['controller'];
$action = $this->_noauth['action'];
} else {
// Permission to access resource denied. Send to error page.
$module = $this->_noauth['module'];
$controller = $this->_noauth['controller'];
$action = $this->_noauth['action'];
}
}$request->setModuleName($module);
$request->setControllerName($controller);
$request->setActionName($action);
}On Mon, Sep 29, 2008 at 4:24 PM, Bradley Holt <bradley.holt@foundline.com> wrote:
Actually, I think it's within the first code snippet you sent :-)On Mon, Sep 29, 2008 at 10:07 AM, Jigal sanders <jigalroecha@gmail.com> wrote:
Well,
I have a plugin which a preDispach function.
Within the predispach I have the following
if ($isDispatchable && !$this->_acl->isAllowed($role, $resource, $action)) {
if (!$this->_auth->hasIdentity()) {
// Not logged in, send to login page
$module = $this->_noauth['module'];
$controller = $this->_noauth['controller'];
$action = $this->_noauth['action'];
} else {
// Permission to access resource denied. Send to error page.
$module = $this->_noauth['module'];
$controller = $this->_noauth['controller'];
$action = $this->_noauth['action'];
Here is where you can add some request parameters indicating what "page" (or module/action/params) to come back to. Something like:
$request->setParam('return', array(
'module' => $request->getModuleName(),
'controller' => $request->getControllerName(),
'action' => $request->getActionName(),
));
You would then need to retrieve the value of the 'return' param in your login action and use that once the user has authenticated. Like I said, you may need to also save that to a session variable (or include it in each login submission) so it can persist across multiple login attempts.
}
}
$request->setModuleName($module);
$request->setControllerName($controller);
$request->setActionName($action);
Is it just a matter of changing this code?On Mon, Sep 29, 2008 at 2:00 PM, Bradley Holt <bradley.holt@foundline.com> wrote:
You would have to implement this in your application's logic - I don't know of anything in Zend Framework that does this specifically. When you forward to the login page, include parameters indicating the page from which you forwarded. When the login is complete, use those parameters to forward back to that original page (you may have to save those parameters to a session variable so they persist across multiple login attempts).--
On Mon, Sep 29, 2008 at 6:52 AM, Jigal sanders <jigalroecha@gmail.com> wrote:Hello everyone,I am using Zend_Acl in combination with login.Every time when I try to go to a page, the system checks if I am logged in. In case I'm not, it redirects me to a login page. Here I can enter my credentials and log in again.But when I am logged in it doesn't redirect me to the page I wanted to get originally. How can I make sure it redirects me to the page i wanted originally?Thanks,J. Sanders
Bradley Holt
bradley.holt@foundline.com
----
Met vriendelijke groet,
Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489
--
Bradley Holt
bradley.holt@foundline.com
没有评论:
发表评论