I keep getting users that try to 'sign in' using the 'sign up' form. It has a lot to do with design choices, but I really like the idea of a catch all.
I just sort of found my own solution to this. I don't love it, but it was pretty simple (once I finally figured it out). I overrode the RegistrationsController as detailed here on stackoverflow. It's the registrations form that I have on the main page of my site for several reasons, so it seemed fitting to do it there.
You'll need to create the app/controllers/registrations_controller.rb and put the code in there:
# app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
def new
super
end
def create
# This is where the magic happens. We actually check the validity of the
# username (an email in my case) and password manally.
email = params[:user][:email]
if user = User.find_by_email(email)
if user.valid_password?(params[:user][:password])
sign_in(user)
redirect_to '/'
return
end
end
# Default devise stuff
build_resource(sign_up_params)
resource_saved = resource.save
yield resource if block_given?
if resource_saved
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
@validatable = devise_mapping.validatable?
if @validatable
@minimum_password_length = resource_class.password_length.min
end
respond_with resource
end
end
def update
super
end
end
You'll need to be sure to configure your routes to use this controller as detailed in that other SO post I linked to above.
# app/config/routes.rb
devise_for :users, :controllers => {:registrations => "registrations"}
Good luck!