Acts_as_authenticated, bad password

I just installed this and for the most part it works great, and all in
about 1/2 an hour! Nice. But I have just one small problem. I would
have expected an error message if login fails, but it just stays on
the login page. I tried adding an “else” to the login method of the
AccountController, but the flash message doesn’t show up. I’m missing
something obvious here probably…

def login
return unless request.post?
self.current_user = User.authenticate(params[:login],
params[:password])
if logged_in?
if params[:remember_me] == “1”
self.current_user.remember_me
cookies[:auth_token] = { :value =>
self.current_user.remember_token , :expires =>
self.current_user.remember_token_expires_at }
end
redirect_back_or_default(:controller => ‘/account’, :action =>
‘index’)
flash[:notice] = “Logged in successfully”
else #my added code
flash[:warning] = ‘Login failed’ #my added code
end #my added code
end

Hi

Try it:

if logged_in?
  if params[:remember_me] == "1"
    self.current_user.remember_me
    cookies[:auth_token] = { :value =>

self.current_user.remember_token , :expires =>
self.current_user.remember_token_expires_at }
end
redirect_back_or_default(:controller => ‘/home’, :action =>
‘teste’)
flash[:notice] = “Login successfully”
else
flash[:notice] = “Login ou senha failed”
end

If you really need flash[:warning] because some specific formatation in
your
layout, you have change layout and add <%= flash[:warning] %>

dailer wrote:

  flash[:notice] = "Logged in successfully"
else    
  flash[:warning] = 'Login failed' #my added code

I think most default/scaffold views in Rails only show notices

e.g.
flash[:notice]

You probably need to improve your flash message code to include
:warning, this was discussed recently on this list.
http://groups.google.com/group/rubyonrails-talk/search?hl=en&group=rubyonrails-talk&q=simple+exists%3F+question&qt_g=Search+this+group

cheers,

Anthony R.