Case insensitive login

21 views
Skip to first unread message

Jim Harvey

unread,
Sep 14, 2011, 1:18:05 PM9/14/11
to hobo...@googlegroups.com
This is a bit of a follow-up to the last question I posted regarding case sensitive searching using Postgres. The problem I have now is that users log in with their email address, which is always converted to lowercase when an account is created. However, some users might use capital letters when they attempt to log in. They SHOULD be to do that. However, right now we have to specify on the log in page that they use lowercase only, which, to me, seems unprofessional. 

So, where can I convert their input to lowercase so that the email matches when they attempt to log in? I don't want to completely overwrite hobo's login action in the controller and the options I can pass to hobo_login do not help in this situation. Has anyone else run into this problem? Please let me know if I'm missing something. Thanks!

Matt Jones

unread,
Sep 14, 2011, 2:21:52 PM9/14/11
to hobo...@googlegroups.com

On Sep 14, 2011, at 1:18 PM, Jim Harvey wrote:

> This is a bit of a follow-up to the last question I posted regarding case sensitive searching using Postgres. The problem I have now is that users log in with their email address, which is always converted to lowercase when an account is created. However, some users might use capital letters when they attempt to log in. They SHOULD be to do that. However, right now we have to specify on the log in page that they use lowercase only, which, to me, seems unprofessional.
>
> So, where can I convert their input to lowercase so that the email matches when they attempt to log in? I don't want to completely overwrite hobo's login action in the controller and the options I can pass to hobo_login do not help in this situation. Has anyone else run into this problem? Please let me know if I'm missing something. Thanks!

The quickest solution I can think of would be to add a before_filter in your UsersController:

class UsersController < ApplicationController

hobo_user_controller

auto_actions :all

before_filter :normalize_login, :only => [:login, :forgot_password]

protected

def normalize_login
params[:login].downcase!
params[:email_address].downcase!
end

end

You didn't ask about the forgot password part, but an identical argument applies to that situation...

--Matt Jones

Jim Harvey

unread,
Sep 14, 2011, 5:24:41 PM9/14/11
to hobo...@googlegroups.com
Great advice Matt, thank you. That was exactly what I needed. And good point about forgot password!
Reply all
Reply to author
Forward
0 new messages