On Apr 14, 3:21 pm, Mariano Iglesias <[email protected]>
wrote:
> That is correct, the $this->Session->flash('auth'); message is not part of
> the layout
> because I relayed on people following:
>
> http://book.cakephp.org/view/1252/Displaying-Auth-Error-Messages
"In order to show all normal flash messages and auth flash messages
for all views add the following two lines to the views/layouts/
default.ctp file in the body section preferable before the
content_for_layout line."
Are you pointing at the right section?
>
> I should've added an Information Box to clear it out :(
>
> Anyway if you get the flash messages, it should be consumed by the login
> action. Meaning that if you enter wrong credentials, and thus the login
> message shows again, then the $this->Session->flash('auth') line should
> consume the message.
I would guess (that recipe isn't in my RAW pdf, which I haven't
updated) the issue is that if you rely on auth to log you in by
username - and rely on the users' login action to log you in by email
that means if you login by email the following happens:
auth startup
(auto) auth->login
fail
add flash message
run login ation
try to login
success
redirect user
There's nothing in the auth component to clear out the auth error
message upon login, therefore the "sorry, couldn't log you in" message
is (obviously) still in the session - and you'll see it on the next
page to render.
> What you can do is remove the $this->Session->flash('auth') from your
> layout, and instead place it in your app/views/users/login.ctp view, since
> that's where the user will be redirected if there's an auth error anyway.
Forgive me for saying that's a horrible idea. Why not just session-
>delete the flash message in the controller action after successfully
logging in a user?
Or
1. disable the auth component in the before filter
2. in your login action do $this->data = $this->hashPasswords($this-
>data);
3. Find user id matching password & (email | username)
4. call $this->Auth->login(id); if there is an id
5. $this->redirect($this->Auth->redirect(), null, true); if they
succeeded to login
6. $this->Session->setFlash($this->Auth->loginError, $this->Auth-
>flashElement, array(), 'auth'); if they failed
while more lines of code that's actually a lot simpler IMO - one
attempt to login and not 2. no magic = clearer.
hth,
AD
--
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