Ok, I just tried setting the loginRedirect and still nothing happens, as in I'm not redirected, again there were no errors shown and I don't know if the login was successful.
The only difference now that loginRedirect is set is after I click login and am sent back to the login page the password field I think contains the hashed password of the user account logging in. Thanks for the help so far, its annoying the things that you think are the easiest to implement are actually the hardest. Felix On 18 July 2010 09:37, Felix <[email protected]> wrote: > 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 <[email protected]> wrote: >> On Sat, Jul 17, 2010 at 10:31 AM, Felix <[email protected]> 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 [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 > 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 [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
