Can't log in with "username" (some hidden JS blocking)

157 views
Skip to first unread message

Tim Hermans

unread,
Apr 5, 2011, 11:30:50 AM4/5/11
to plataforma...@googlegroups.com
I used the instructions here: "https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign_in-using-their-username-or-email-address" to set up username and email address login.

This used to work fine.

Now I'm using the latest git master of devise and it won't let me log in with a username.  Seems like some javascript is blocking it: I get a tooltip on the login input field saying "Please enter an email address".

But I can't find it anywhere!

$ [/tmp/devise]
➜ git status
# On branch master
nothing to commit (working directory clean)
$ [/tmp/devise]
➜ grep -r "Please enter" *         
$ [/tmp/devise]

The model works fine:

ruby-1.9.2-p180 :003 > User.find_for_database_authentication(:login => "username")
#<User:0xb592a58> {
                     :id => 1,
                  :email => "...

What gives?



Tim Hermans

unread,
Apr 5, 2011, 2:42:08 PM4/5/11
to plataforma...@googlegroups.com
Aha!  It's Firefox4's HTML5 field validation.  Sneaky.

The new session view, "devise/sessions/new.html.erb" has by default:

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
  <p><%= f.label :email %><br />
  <%= f.email_field :email %></p>


If you go with username and email auth, then you need to change the "email_field" to "text_field", otherwise Firefox4's form validation will expect an email address in there.

Carlos Antonio da Silva

unread,
Apr 5, 2011, 2:52:14 PM4/5/11
to plataforma...@googlegroups.com, Tim Hermans
You can also try adding a :novalidate => true option to the :html hash on the form_for call, and it'll instruct the browser to not validate the form using html5 validation features. This way you can still use the :email_field.
--
At.
Carlos A. da Silva
Reply all
Reply to author
Forward
0 new messages