I am able to log in with a username and an email. The problem is after
I sign in I get an error message. I took your code, and noticed this
line is not in your default.ctp : <?php echo $this->Session-
>flash('auth'); ?> and when I add this line, I get the following error
after signing in: "Login failed. Invalid username or password." If I
try to sign in with wrong credentials I get the same error message,
but the application doesn't redirect to the last page I was at before
the login. So basically the error message is always on.On Apr 12, 9:27 pm, "mariano.iglesias" <[email protected]> wrote: > I just followed the recipe from scratch and found no issues. I am able > to log in with either a user account, or an email. Can you set DEBUG > to 2 (in your app/config/core.php file) and paste the queries that are > shown? > > On Apr 11, 5:42 pm, john lyles <[email protected]> wrote: > > > > > > > > > Hi Everyone, > > I am following a recipe from 'Cakephp 1.3 Application Development > > Cookbook' ByMarianoIglesiasand I am stuck with the recipe 'Allowing > > logins with username or email' on page 16 of the book. > > > The recipe works except one problem which I cannot figure out. If I > > login with the email instead of the username the loginError message > > flashes on the screen. This doesn't happen if I login using the > > username. > > > I should note also that you have to do the basic auth setup before you > > can do this recipe, and the basic setup works with no issues that I > > have noticed so far. > > > This is what the login action of the Users Controller looks like: > > > public function login() { > > if ( > > !empty($this->data) && > > !empty($this->Auth->data['User']['username']) && > > !empty($this->Auth->data['User']['password']) > > ) { > > $user = $this->User->find( > > 'first', array( > > 'conditions' => array( > > 'User.email' => $this->Auth->data['User']['username'], > > 'User.password' => $this->Auth->data['User']['password'] > > ), > > 'recursive' => -1 > > )); > > if (!empty($user) && $this->Auth->login($user)) { > > if ($this->Auth->autoRedirect) { > > $this->redirect($this->Auth->redirect()); > > } > > } else { > > $this->Session->setFlash($this->Auth->loginError, $this->Auth- > > > >flashElement, array(), 'auth'); > > } > > } > > } -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
