I'm sorry, but I can't understand why it should works.. It seems to me
that in that way the login page will redirect you to the page you come
from, without execute any login procedure... Perhaps I'm wrong..
On 6 Lug, 22:52, Chez17 <[EMAIL PROTECTED]> wrote:
> Using Eric's post, I created a very simple way to get theAuth
> component toredirectto the referring page no matter what. I think
> its userful:
>
> <?php
> class UsersController extends AppController
> {
> var $name = "Users";
>
> var $components = array("Auth");
>
> function beforeFilter()
> {
> $this->Auth->autoRedirect = false;
> }
>
> functionlogin()
> {
> $this->redirect($_SERVER['HTTP_REFERER']);
> }
>
> }
>
> On Jul 2, 1:56 pm, Rich <[EMAIL PROTECTED]> wrote:
>
> > that worked perfectly for me. thanks Eric!
>
> > On Jul 2, 12:32 pm, Eric <[EMAIL PROTECTED]> wrote:
>
> > > I had a similar problem and here is what I did.
>
> > > 1. Change your setupAuth function like this
> > > function setupAuth( )
> > > {
> > > ...
> > > $this->Auth->loginRedirect = '/users/loginRedirect';
> > > $this->Auth->autoRedirect = false; // <-- handle redirecting yourself
>
> > > }
>
> > > 2. create a loginRedirect action which determines where to goaftera
> > >loginhas succeeded
>
> > > function loginRedirect()
> > > {
> > > $this->log('users/LoginRedirect()', LOG_DEBUG);
> > > if (parent::getAuthGroup() === "ADMIN")
> > > {
> > > $this->log('--redirecting to admin', LOG_DEBUG);
> > > $this->redirect('/admin/myCtrl/index');
> > > }
> > > else
> > > {
> > > $this->log('--redirecting to normal', LOG_DEBUG);
> > > $this->redirect('/myCtrl/index');
>
> > > }
>
> > > 3. Yourloginaction is pretty simple then
>
> > > functionlogin()
> > > {
> > > if ($this->Auth->login())
> > > {
> > > $this->loginRedirect();
> > > }
> > > else
> > > {
> > > if (!empty($this->data))
> > > $this->Session->setFlash($this->Auth->loginError);
> > > }
>
> > > }
>
> > > I think you can get the page that the user was trying to access via
> > > the session, andredirectthere, but taking them to the front page
> > > works for me
> > > .
> > > Hopefully this helps.
>
> > > -Eric
>
> > > On Jul 2, 10:44 am, leo <[EMAIL PROTECTED]> wrote:
>
> > > > On 2 Jul, 17:27, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote:
>
> > > > > I see what you mean, but I'm not sure that you can put 'action' => '/'
> > > > > or 'controller' => '/'.
>
> > > > Sorry, I missed that. Nope, I wouldn't want to be doing that even if
> > > > it was valid.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---