Update Devise to allow the login field to be username instead of email
This commit is contained in:
parent
336965d845
commit
35f2a92576
5 changed files with 11 additions and 5 deletions
|
@ -6,6 +6,6 @@ class User < ActiveRecord::Base
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
# Setup accessible (or protected) attributes for your model
|
# Setup accessible (or protected) attributes for your model
|
||||||
attr_accessible :email, :password, :password_confirmation, :remember_me
|
attr_accessible :email, :password, :password_confirmation, :remember_me, :username
|
||||||
# attr_accessible :title, :body
|
# attr_accessible :title, :body
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<h2>Sign in</h2>
|
<h2>Sign in</h2>
|
||||||
|
|
||||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||||
<div><%= f.label :email %><br />
|
<div><%= f.label :username %><br />
|
||||||
<%= f.email_field :email, :autofocus => true %></div>
|
<%= f.text_field :username, :autofocus => true %></div>
|
||||||
|
|
||||||
<div><%= f.label :password %><br />
|
<div><%= f.label :password %><br />
|
||||||
<%= f.password_field :password %></div>
|
<%= f.password_field :password %></div>
|
||||||
|
|
|
@ -23,7 +23,7 @@ Devise.setup do |config|
|
||||||
# session. If you need permissions, you should implement that in a before filter.
|
# session. If you need permissions, you should implement that in a before filter.
|
||||||
# You can also supply a hash where the value is a boolean determining whether
|
# You can also supply a hash where the value is a boolean determining whether
|
||||||
# or not authentication should be aborted when the value is not present.
|
# or not authentication should be aborted when the value is not present.
|
||||||
# config.authentication_keys = [ :email ]
|
config.authentication_keys = [ :username ]
|
||||||
|
|
||||||
# Configure parameters from the request object used for authentication. Each entry
|
# Configure parameters from the request object used for authentication. Each entry
|
||||||
# given should be a request method and it will automatically be passed to the
|
# given should be a request method and it will automatically be passed to the
|
||||||
|
|
5
db/migrate/20130413054153_add_username_to_users.rb
Normal file
5
db/migrate/20130413054153_add_username_to_users.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddUsernameToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :username, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20130412012722) do
|
ActiveRecord::Schema.define(:version => 20130413054153) do
|
||||||
|
|
||||||
create_table "alerts", :force => true do |t|
|
create_table "alerts", :force => true do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
@ -55,6 +55,7 @@ ActiveRecord::Schema.define(:version => 20130412012722) do
|
||||||
t.string "last_sign_in_ip"
|
t.string "last_sign_in_ip"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
|
t.string "username"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||||
|
|
Loading…
Reference in a new issue