Hi,

I was under the impression that Auth would redirect to the controller
and action they were trying to access before being redirected to the
login page.

If I specify a redirect will it apply to all controllers/actions using
Auth,

e.g. If I set the Auth redirect to "accounts/view" then someone
logging in from "discussions/new" is going to be redirected to
"accounts/view" rather than "discussions/new".

I'm not really sure how that all works, so sorry if that makes no
sense.

Felix

On Jul 17, 4:25 pm, cricket <zijn.digi...@gmail.com> wrote:
> On Sat, Jul 17, 2010 at 10:31 AM, Felix <fe...@felixfennell.co.uk> wrote:
> > Hi,
>
> > I'm trying to add the Auth component to my app,
>
> > I'm using a custom database/model called accounts (database/table:
> > accounts, model: Account).
>
> > The database uses the fields;
>
> > = e-mail (acts as username)
> > = password
> > = ( ... other non-important fields)
>
> > I've configured the app controller as such;
>
> > ==
>
> > <?php
> > class AppController extends Controller {
>
> >    var $components = array('Auth','Session');
>
> >    function beforeFilter() {
> >       parent::beforefilter();
> >       //configure AUTH component
> >       $this->Auth->userModel = 'Account';
> >       $this->Auth->loginAction = '/Accounts/login';
> >       $this->Auth->fields =
> > array('username'=>'email','password'=>'password');
> >       $this->Auth->allow('*');
> >       $this->Auth->userScope = array('Account.status' => 'normal');
> >       $this->Auth->loginError = 'Invalid login details - please try
> > again / reset password';
> >       $this->Auth->authError = 'You must be logged in to visit -
> > please login / register';
> >    }
> > }
> > ?>
>
> > ==
>
> > In the accounts controller I've got;
>
> > ==
>
> > <?php
>
> > class AccountsController extends AppController {
> >    var $name = 'Accounts';
>
> >    function beforeFilter() {
> >       parent::beforeFilter();
> >       $this->Auth->deny('index');
> >    }
>
> >    function login() {
> >    }
>
> >    function logout() {
> >        $this->redirect($this->Auth->logout());
> >    }
>
> > }
> > ?>
>
> > However when I login I end up back at "example.com/accounts/login".
> > Every time I login I get sent back to this action, there is no error
> > message so I assume it is correctly checking the database or I'd get
> > an ugly php error, and cake doesn't produce an auth error.
>
> > So I thought either the login is working and for some reason always
> > redirects back to the login page, or the login is nether actually
> > being done.
>
> You need to tell Auth where to redirect in AppController::beforeFilter()
>
> $this->Auth->loginRedirect = array(
>         'controller' => ...,
>         'action' => ...
> );

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to