if it is an AJAX request or a classic HTTP request.
In fact, I don't want to redirect the user to login action. Simply I
can have a user who IS ALREADY LOGGED IN and click on an AJAX action
that he can't access. So I want to display a dialog message that
alerts him he can't access this action. Moreover I have lot of
controllers and actions, ideally the solution would apply for all of
them.
On Feb 23, 11:19 am, Tilen Majerle <tilen.maje...@gmail.com> wrote:
> and i forgor...maybe you want to disable autoRedirect option....http://book.cakephp.org/view/1274/autoRedirect
> --
> Lep pozdrav, Tilen Majerlehttp://majerle.eu
>
> 2011/2/23 Tilen Majerle <tilen.maje...@gmail.com>
>
> > first, use RequestHandler component....then check if is Ajax request so...
>
> > if ($this->RequestHandler->isAjax())
> > {
> > $this->layout = 'ajax';
> > }
> > else //not ajax, make redirect
> > {
> > $this->redirect('/');
> > }
>
> > make a layout new and name it "ajax.ctp" and put this inside:
> > <?php print $contents_for_layout; ?>
>
> > and in a view of controller, action, do this:
>
> > <?php print $this->Session->flash('auth'); ?>
>
> > so if i explain, if there is no ajax call, it will redirect user, if IS
> > ajax, then will load new layout, which will display only view file of some
> > Controller/action idk like users/login.ctp and there inside login.ctp is
> > SessionHelper::flash() method which will display if any errors accured when
> > login...do u understand?
>
> > --
> > Lep pozdrav, Tilen Majerle
> >http://majerle.eu
>
> > 2011/2/23 Julien Barbedette <barbedette.jul...@gmail.com>
>
> > Hi,
>
> >> By default, the Auth component used with the ACL component redirects
> >> the user to the referer when this one can't access to the controller/
> >> action (last lines of method startup in auth component):
>
> >> if ($this->isAuthorized($type)) {
> >> return true;
> >> }
>
> >> $this->Session->setFlash($this->authError,
> >> $this->flashElement,
> >> array(), 'auth');
> >> $controller->redirect($controller->referer(), null, true);
> >> return false;
>
> >> This is ok when you make a classic HTTP query but what about an AJAX
> >> query? In my case, I don't want to display a complete page in my AJAX
> >> dialog but only a message alerting the user that he can't access to
> >> the page.
>
> >> Any idea to manage that or if a solution already exists?
>
> >> Thanks
>
> >> --
> >> Our newest site for the community: CakePHP Video Tutorials
> >>http://tv.cakephp.org
> >> Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> >> others with their CakePHP related questions.
>
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscribe@googlegroups.com For more options, visit this group
> >> athttp://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment