added token to users model and generate token method to users controller
This commit is contained in:
@@ -81,5 +81,11 @@ private
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_token(column)
|
||||||
|
begin
|
||||||
|
self[column] = SecureRandom.urlsafe_base64
|
||||||
|
end while User.exists?(column => self[column])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddAuthTokenToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :auth_token, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
+2
-1
@@ -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 => 20131113200708) do
|
ActiveRecord::Schema.define(:version => 20140312002642) do
|
||||||
|
|
||||||
create_table "benefits", :force => true do |t|
|
create_table "benefits", :force => true do |t|
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
@@ -83,6 +83,7 @@ ActiveRecord::Schema.define(:version => 20131113200708) do
|
|||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
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 "auth_token"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "work_infos", :force => true do |t|
|
create_table "work_infos", :force => true do |t|
|
||||||
|
|||||||
Reference in New Issue
Block a user