I had some head-scratching at first but found that most of the things I wanted to change, and was struggling with, was already the default behavior.
Redirection after session timeout (any redirection in fact) jumps back to the requested page after login (or to your specified loginRedirect if no referer could be found). This is the built in behaviour. Pointing to http://my.site/protected/action will jump to the login- page and then back after login without any help from me. My 1.2 AppController without any ACL stuff looks like this. It is pretty straight from the popular tutorials with the possible exception that I set the userdata in the beforeFilter so that any view and layout can use the userdata. var $publicControllers = array('pages','dashboard','gateway'); function beforeFilter() { if ( isset($this->Auth) ) { $this->Auth->fields = array('username' => 'email', 'password' => 'password'); $this->Auth->loginAction = '/users/login'; $this->Auth->autoRedirect = true; $this->Auth->loginRedirect = '/'; // $this->Auth->userScope = array('User.disabled' => 0); $this->Auth->logoutRedirect = '/'; $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; $this->Auth->authError = 'Hey! You can't do that.'; if (in_array(low($this->params['controller']), $this- >publicControllers)) { $this->Auth->allow(); } $this->set('auth', $this->Auth->user() ); } } On Feb 5, 11:19 am, Tim W <[EMAIL PROTECTED]> wrote: > Do you have sample vode for those Andy? I've also been banging my head > against 1.2 Auth for about 3 days and i'm tempted to rip it out and > write my own - which I expect to take about 2 hours. > > On Feb 5, 11:08 pm, AD7six <[EMAIL PROTECTED]> wrote: > > > > 2. When refresh a exprired auth page , it'll jump to login page. But > > > how can go back to the same page after relogin > > > In your login function add this sort of logic: > > > if ( the referer isn't in the session) { > > put it in the session > > > } > > > In your app controller before filter tell the auth component to > > redirect after login to the location you put in the session > > > hth, > > > AD --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
