# failed login flash.now[: attempts] = @params[: attempts].to_i + 1 if flash[: attempts] > 3 flash.now[: error] = 'You seem to be having trouble logging in. If you want your password reset, simply try to log in with the password "forgot'" elsif @params[: user][: password].include?('forgot') User.find_by_email(@params[: email]).reset_password flash.now[: notice] = 'Your password has been reset an emailed to you.' else flash.now[: error] = 'You provided an incorrect email and password combination.' end
More people should do this. It one thing I haven't seen anywhere else and one thing that is more rare than it should be. First of all, it will reset your password and email it to you if you enter 'forgot' in the password box. Secondly, it suggests that you get your password reset if you try to log in with the wrong password too many times. Simple things, but they're worth paying attention to.