From 4014dfc777c83f9f97491676b9ffd0aadf2250c4 Mon Sep 17 00:00:00 2001 From: jywarren Date: Tue, 4 Jul 2017 13:10:53 -0400 Subject: [PATCH 01/20] bio field now part of User; status moved off of DrupalUser --- app/controllers/users_controller.rb | 4 ++-- app/models/drupal_users.rb | 16 ------------- app/models/user.rb | 4 ---- .../20170704165711_add_user_bio_and_token.rb | 23 +++++++++++++++++++ 4 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 db/migrate/20170704165711_add_user_bio_and_token.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b19e227458..547f8f7855 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -19,7 +19,7 @@ def create flash[:warning] = I18n.t('users_controller.account_migrated_create_new_password') redirect_to "/profile/edit" else - @user.drupal_user.set_bio(params[:drupal_user][:bio]) + @user.update_attribute(:bio, params[:drupal_user][:bio]) @user.add_to_lists(['publiclaboratory']) flash[:notice] = I18n.t('users_controller.registration_successful').html_safe flash[:warning] = I18n.t('users_controller.spectralworkbench_or_mapknitter', :url1 => "'#{session[:openid_return_to]}'").html_safe if session[:openid_return_to] @@ -45,7 +45,7 @@ def update if current_user @user = current_user @user.attributes = params[:user] - @user.drupal_user.set_bio(params[:drupal_user][:bio]) + @user.update_attribute(:bio, params[:drupal_user][:bio]) @user.save({}) do |result| if result if session[:openid_return_to] # for openid login, redirects back to openid auth process diff --git a/app/models/drupal_users.rb b/app/models/drupal_users.rb index ebfb413ae8..4c81eb9d8d 100644 --- a/app/models/drupal_users.rb +++ b/app/models/drupal_users.rb @@ -118,22 +118,6 @@ def profile_values drupal_profile_values end - def set_bio(text) - bio = DrupalProfileValue.find_by_uid(uid, conditions: { fid: 7 }) - bio = DrupalProfileValue.new(fid: 7, uid: uid) if bio.nil? - bio.value = text - bio.save! - end - - def bio - bio = DrupalProfileValue.find_by_uid(uid, conditions: { fid: 7 }) - if bio - bio.value || '' - else - '' - end - end - def notes user.notes end diff --git a/app/models/user.rb b/app/models/user.rb index 5a88dabe8b..91b1c34cc0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -96,10 +96,6 @@ def generate_reset_key key end - def bio - drupal_user.bio - end - def uid drupal_user.uid end diff --git a/db/migrate/20170704165711_add_user_bio_and_token.rb b/db/migrate/20170704165711_add_user_bio_and_token.rb new file mode 100644 index 0000000000..d136eb861e --- /dev/null +++ b/db/migrate/20170704165711_add_user_bio_and_token.rb @@ -0,0 +1,23 @@ +class AddUserBioAndToken < ActiveRecord::Migration + def up + add_column :rusers, :bio, :text + add_column :rusers, :token, :string + add_column :rusers, :status, :integer, default: 0 + remove_column :rusers, :location_privacy + + # copy bios into new fields for non-spam users + DrupalUsers.where('status != 0').each do |u| + user = u.user + user.status = u.status + user.bio = DrupalProfileValue.find_by_uid(user.id, conditions: { fid: 7 }) + user.save({}) + end + end + + def down + remove_column :rusers, :bio + remove_column :rusers, :token + remove_column :rusers, :status + add_column :rusers, :location_privacy, :boolean + end +end From 44011ae1b2246ce130c8b1f46d3285cf16fbf361 Mon Sep 17 00:00:00 2001 From: jywarren Date: Tue, 4 Jul 2017 13:26:21 -0400 Subject: [PATCH 02/20] schema.rb --- db/schema.rb.example | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/schema.rb.example b/db/schema.rb.example index b1a21c74e8..bc68210f4e 100644 --- a/db/schema.rb.example +++ b/db/schema.rb.example @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20170208174046) do +ActiveRecord::Schema.define(:version => 20170704165711) do create_table "answer_selections", :force => true do |t| t.integer "user_id" @@ -190,10 +190,10 @@ ActiveRecord::Schema.define(:version => 20170208174046) do add_index "impressions", ["controller_name", "action_name", "request_hash"], :name => "controlleraction_request_index" add_index "impressions", ["controller_name", "action_name", "session_hash"], :name => "controlleraction_session_index" add_index "impressions", ["impressionable_type", "impressionable_id", "ip_address"], :name => "poly_ip_index" - add_index "impressions", ["impressionable_type", "impressionable_id", "params"], :name => "poly_params_request_index", :unique => false, :length => { "params" => 255 } + add_index "impressions", ["impressionable_type", "impressionable_id", "params"], :name => "poly_params_request_index" add_index "impressions", ["impressionable_type", "impressionable_id", "request_hash"], :name => "poly_request_index" add_index "impressions", ["impressionable_type", "impressionable_id", "session_hash"], :name => "poly_session_index" - add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index", :unique => false, :length => { "message" => 255 } + add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index" add_index "impressions", ["user_id"], :name => "index_impressions_on_user_id" create_table "location_tags", :force => true do |t| @@ -350,10 +350,11 @@ ActiveRecord::Schema.define(:version => 20170208174046) do t.string "photo_file_name" t.string "photo_content_type" t.string "photo_file_size" - t.boolean "location_privacy", :default => true + t.text "bio" + t.string "token" + t.integer "status", :default => 0 end - add_index "rusers", ["location_privacy"], :name => "index_rusers_on_location_privacy" add_index "rusers", ["username"], :name => "index_rusers_on_username" create_table "searches", :force => true do |t| From b849133184bf0ef6db18ebe5edcf320db4a9ab3c Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Tue, 4 Jul 2017 15:53:44 -0400 Subject: [PATCH 03/20] Update 20170704165711_add_user_bio_and_token.rb --- db/migrate/20170704165711_add_user_bio_and_token.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20170704165711_add_user_bio_and_token.rb b/db/migrate/20170704165711_add_user_bio_and_token.rb index d136eb861e..08ff54b0bc 100644 --- a/db/migrate/20170704165711_add_user_bio_and_token.rb +++ b/db/migrate/20170704165711_add_user_bio_and_token.rb @@ -1,6 +1,6 @@ class AddUserBioAndToken < ActiveRecord::Migration def up - add_column :rusers, :bio, :text + add_column :rusers, :bio, :text, limit: 2147483647 add_column :rusers, :token, :string add_column :rusers, :status, :integer, default: 0 remove_column :rusers, :location_privacy From 7092a8a2b034698a3868ee21cd2b0864adfecba6 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Thu, 6 Jul 2017 22:32:18 +0530 Subject: [PATCH 04/20] Use SecureRandom.uuid for generating per-user tokens (#253) --- db/migrate/20170704165711_add_user_bio_and_token.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/migrate/20170704165711_add_user_bio_and_token.rb b/db/migrate/20170704165711_add_user_bio_and_token.rb index 08ff54b0bc..c6997d729b 100644 --- a/db/migrate/20170704165711_add_user_bio_and_token.rb +++ b/db/migrate/20170704165711_add_user_bio_and_token.rb @@ -10,6 +10,7 @@ def up user = u.user user.status = u.status user.bio = DrupalProfileValue.find_by_uid(user.id, conditions: { fid: 7 }) + user.token = SecureRandom.uuid user.save({}) end end @@ -20,4 +21,7 @@ def down remove_column :rusers, :status add_column :rusers, :location_privacy, :boolean end + + drop_table: searches + drop_table: location_tags end From eb697c6356d9993734da7f53a7f78ff68dda7b76 Mon Sep 17 00:00:00 2001 From: jywarren Date: Thu, 6 Jul 2017 14:51:03 -0400 Subject: [PATCH 05/20] schema and tweaks --- .../20170704165711_add_user_bio_and_token.rb | 3 -- db/schema.rb.example | 42 ++++--------------- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/db/migrate/20170704165711_add_user_bio_and_token.rb b/db/migrate/20170704165711_add_user_bio_and_token.rb index c6997d729b..488b238dc7 100644 --- a/db/migrate/20170704165711_add_user_bio_and_token.rb +++ b/db/migrate/20170704165711_add_user_bio_and_token.rb @@ -21,7 +21,4 @@ def down remove_column :rusers, :status add_column :rusers, :location_privacy, :boolean end - - drop_table: searches - drop_table: location_tags end diff --git a/db/schema.rb.example b/db/schema.rb.example index bc68210f4e..565d970e6b 100644 --- a/db/schema.rb.example +++ b/db/schema.rb.example @@ -196,20 +196,6 @@ ActiveRecord::Schema.define(:version => 20170704165711) do add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index" add_index "impressions", ["user_id"], :name => "index_impressions_on_user_id" - create_table "location_tags", :force => true do |t| - t.integer "uid" - t.string "location" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.decimal "lat", :precision => 15, :scale => 10 - t.decimal "lon", :precision => 15, :scale => 10 - t.string "country" - t.string "state" - t.string "city" - t.integer "nid" - t.boolean "location_privacy" - end - create_table "node", :primary_key => "nid", :force => true do |t| t.integer "vid", :default => 0, :null => false t.string "type", :limit => 32, :default => "", :null => false @@ -335,42 +321,28 @@ ActiveRecord::Schema.define(:version => 20170704165711) do t.string "crypted_password" t.string "password_salt" t.string "persistence_token" - t.integer "login_count", :default => 0, :null => false - t.integer "failed_login_count", :default => 0, :null => false + t.integer "login_count", :default => 0, :null => false + t.integer "failed_login_count", :default => 0, :null => false t.datetime "last_request_at" t.datetime "current_login_at" t.datetime "last_login_at" t.string "current_login_ip" t.string "last_login_ip" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "openid_identifier" - t.string "role", :default => "basic" + t.string "role", :default => "basic" t.string "reset_key" t.string "photo_file_name" t.string "photo_content_type" t.string "photo_file_size" - t.text "bio" + t.text "bio", :limit => 2147483647 t.string "token" - t.integer "status", :default => 0 + t.integer "status", :default => 0 end add_index "rusers", ["username"], :name => "index_rusers_on_username" - create_table "searches", :force => true do |t| - t.string "key_words" - t.string "title" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "main_type" - t.string "note_type" - t.string "created_by" - t.string "max_date" - t.string "language" - t.string "min_date" - end - create_table "tag_selections", :id => false, :force => true do |t| t.integer "user_id" t.integer "tid" From d47eae8b6c5c7cfa40ad4f3b8db50f1d84955305 Mon Sep 17 00:00:00 2001 From: jywarren Date: Thu, 6 Jul 2017 14:58:55 -0400 Subject: [PATCH 06/20] schema example tweak --- .../20170704165711_add_user_bio_and_token.rb | 2 + db/schema.rb.example | 49 ++++++++++++++----- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/db/migrate/20170704165711_add_user_bio_and_token.rb b/db/migrate/20170704165711_add_user_bio_and_token.rb index 488b238dc7..fe790a0399 100644 --- a/db/migrate/20170704165711_add_user_bio_and_token.rb +++ b/db/migrate/20170704165711_add_user_bio_and_token.rb @@ -13,6 +13,8 @@ def up user.token = SecureRandom.uuid user.save({}) end + drop_table :location_tags + drop_table :searches end def down diff --git a/db/schema.rb.example b/db/schema.rb.example index 565d970e6b..b1a21c74e8 100644 --- a/db/schema.rb.example +++ b/db/schema.rb.example @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20170704165711) do +ActiveRecord::Schema.define(:version => 20170208174046) do create_table "answer_selections", :force => true do |t| t.integer "user_id" @@ -190,12 +190,26 @@ ActiveRecord::Schema.define(:version => 20170704165711) do add_index "impressions", ["controller_name", "action_name", "request_hash"], :name => "controlleraction_request_index" add_index "impressions", ["controller_name", "action_name", "session_hash"], :name => "controlleraction_session_index" add_index "impressions", ["impressionable_type", "impressionable_id", "ip_address"], :name => "poly_ip_index" - add_index "impressions", ["impressionable_type", "impressionable_id", "params"], :name => "poly_params_request_index" + add_index "impressions", ["impressionable_type", "impressionable_id", "params"], :name => "poly_params_request_index", :unique => false, :length => { "params" => 255 } add_index "impressions", ["impressionable_type", "impressionable_id", "request_hash"], :name => "poly_request_index" add_index "impressions", ["impressionable_type", "impressionable_id", "session_hash"], :name => "poly_session_index" - add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index" + add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index", :unique => false, :length => { "message" => 255 } add_index "impressions", ["user_id"], :name => "index_impressions_on_user_id" + create_table "location_tags", :force => true do |t| + t.integer "uid" + t.string "location" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.decimal "lat", :precision => 15, :scale => 10 + t.decimal "lon", :precision => 15, :scale => 10 + t.string "country" + t.string "state" + t.string "city" + t.integer "nid" + t.boolean "location_privacy" + end + create_table "node", :primary_key => "nid", :force => true do |t| t.integer "vid", :default => 0, :null => false t.string "type", :limit => 32, :default => "", :null => false @@ -321,28 +335,41 @@ ActiveRecord::Schema.define(:version => 20170704165711) do t.string "crypted_password" t.string "password_salt" t.string "persistence_token" - t.integer "login_count", :default => 0, :null => false - t.integer "failed_login_count", :default => 0, :null => false + t.integer "login_count", :default => 0, :null => false + t.integer "failed_login_count", :default => 0, :null => false t.datetime "last_request_at" t.datetime "current_login_at" t.datetime "last_login_at" t.string "current_login_ip" t.string "last_login_ip" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "openid_identifier" - t.string "role", :default => "basic" + t.string "role", :default => "basic" t.string "reset_key" t.string "photo_file_name" t.string "photo_content_type" t.string "photo_file_size" - t.text "bio", :limit => 2147483647 - t.string "token" - t.integer "status", :default => 0 + t.boolean "location_privacy", :default => true end + add_index "rusers", ["location_privacy"], :name => "index_rusers_on_location_privacy" add_index "rusers", ["username"], :name => "index_rusers_on_username" + create_table "searches", :force => true do |t| + t.string "key_words" + t.string "title" + t.string "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "main_type" + t.string "note_type" + t.string "created_by" + t.string "max_date" + t.string "language" + t.string "min_date" + end + create_table "tag_selections", :id => false, :force => true do |t| t.integer "user_id" t.integer "tid" From 71802996b7d57be65fc5edaa29babb0abc187345 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Fri, 7 Jul 2017 01:15:33 +0530 Subject: [PATCH 07/20] Patch token (#254) * Use SecureRandom.uuid for generating per-user tokens * Remove redundant drop_table calls * Run migration and copy database schema --- db/schema.rb.example | 49 ++++++++++---------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/db/schema.rb.example b/db/schema.rb.example index b1a21c74e8..565d970e6b 100644 --- a/db/schema.rb.example +++ b/db/schema.rb.example @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20170208174046) do +ActiveRecord::Schema.define(:version => 20170704165711) do create_table "answer_selections", :force => true do |t| t.integer "user_id" @@ -190,26 +190,12 @@ ActiveRecord::Schema.define(:version => 20170208174046) do add_index "impressions", ["controller_name", "action_name", "request_hash"], :name => "controlleraction_request_index" add_index "impressions", ["controller_name", "action_name", "session_hash"], :name => "controlleraction_session_index" add_index "impressions", ["impressionable_type", "impressionable_id", "ip_address"], :name => "poly_ip_index" - add_index "impressions", ["impressionable_type", "impressionable_id", "params"], :name => "poly_params_request_index", :unique => false, :length => { "params" => 255 } + add_index "impressions", ["impressionable_type", "impressionable_id", "params"], :name => "poly_params_request_index" add_index "impressions", ["impressionable_type", "impressionable_id", "request_hash"], :name => "poly_request_index" add_index "impressions", ["impressionable_type", "impressionable_id", "session_hash"], :name => "poly_session_index" - add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index", :unique => false, :length => { "message" => 255 } + add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index" add_index "impressions", ["user_id"], :name => "index_impressions_on_user_id" - create_table "location_tags", :force => true do |t| - t.integer "uid" - t.string "location" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.decimal "lat", :precision => 15, :scale => 10 - t.decimal "lon", :precision => 15, :scale => 10 - t.string "country" - t.string "state" - t.string "city" - t.integer "nid" - t.boolean "location_privacy" - end - create_table "node", :primary_key => "nid", :force => true do |t| t.integer "vid", :default => 0, :null => false t.string "type", :limit => 32, :default => "", :null => false @@ -335,41 +321,28 @@ ActiveRecord::Schema.define(:version => 20170208174046) do t.string "crypted_password" t.string "password_salt" t.string "persistence_token" - t.integer "login_count", :default => 0, :null => false - t.integer "failed_login_count", :default => 0, :null => false + t.integer "login_count", :default => 0, :null => false + t.integer "failed_login_count", :default => 0, :null => false t.datetime "last_request_at" t.datetime "current_login_at" t.datetime "last_login_at" t.string "current_login_ip" t.string "last_login_ip" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "openid_identifier" - t.string "role", :default => "basic" + t.string "role", :default => "basic" t.string "reset_key" t.string "photo_file_name" t.string "photo_content_type" t.string "photo_file_size" - t.boolean "location_privacy", :default => true + t.text "bio", :limit => 2147483647 + t.string "token" + t.integer "status", :default => 0 end - add_index "rusers", ["location_privacy"], :name => "index_rusers_on_location_privacy" add_index "rusers", ["username"], :name => "index_rusers_on_username" - create_table "searches", :force => true do |t| - t.string "key_words" - t.string "title" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "main_type" - t.string "note_type" - t.string "created_by" - t.string "max_date" - t.string "language" - t.string "min_date" - end - create_table "tag_selections", :id => false, :force => true do |t| t.integer "user_id" t.integer "tid" From 21bca1113204535e01e0d2fb5a9c86efbdccdcb8 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Fri, 7 Jul 2017 02:20:25 +0530 Subject: [PATCH 08/20] Patch token (#255) * Use SecureRandom.uuid for generating per-user tokens * Remove redundant drop_table calls * Run migrations and update schema From d943b4cf169f6a564eee848e2bf53c38e3343c4a Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Fri, 7 Jul 2017 03:50:54 +0530 Subject: [PATCH 09/20] Patch token (#256) * Use SecureRandom.uuid for generating per-user tokens * Remove redundant drop_table calls * Fix database inconsistencies --- db/schema.rb.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/schema.rb.example b/db/schema.rb.example index 565d970e6b..ffae3a8847 100644 --- a/db/schema.rb.example +++ b/db/schema.rb.example @@ -190,10 +190,10 @@ ActiveRecord::Schema.define(:version => 20170704165711) do add_index "impressions", ["controller_name", "action_name", "request_hash"], :name => "controlleraction_request_index" add_index "impressions", ["controller_name", "action_name", "session_hash"], :name => "controlleraction_session_index" add_index "impressions", ["impressionable_type", "impressionable_id", "ip_address"], :name => "poly_ip_index" - add_index "impressions", ["impressionable_type", "impressionable_id", "params"], :name => "poly_params_request_index" + add_index "impressions", ["impressionable_type", "impressionable_id", "params"], :name => "poly_params_request_index", :unique => false, :length => { "params" => 255 } add_index "impressions", ["impressionable_type", "impressionable_id", "request_hash"], :name => "poly_request_index" add_index "impressions", ["impressionable_type", "impressionable_id", "session_hash"], :name => "poly_session_index" - add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index" + add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index", :unique => false, :length => { "message" => 255 } add_index "impressions", ["user_id"], :name => "index_impressions_on_user_id" create_table "node", :primary_key => "nid", :force => true do |t| From 49f939ab192f01d8a123a7b39f7b180010d5b6cf Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 6 Jul 2017 18:33:32 -0400 Subject: [PATCH 10/20] Update drupal_users.rb --- app/models/drupal_users.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/drupal_users.rb b/app/models/drupal_users.rb index 4c81eb9d8d..48d6d892d9 100644 --- a/app/models/drupal_users.rb +++ b/app/models/drupal_users.rb @@ -32,6 +32,10 @@ def user User.find_by_username name end + def bio + user.bio + end + def username name end From dc19d1b5f91fb524d1a9d8ced9f867c30cfce516 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 6 Jul 2017 19:00:02 -0400 Subject: [PATCH 11/20] Update _tags_form.html.erb --- app/views/users/_tags_form.html.erb | 250 ---------------------------- 1 file changed, 250 deletions(-) diff --git a/app/views/users/_tags_form.html.erb b/app/views/users/_tags_form.html.erb index c5f54edf08..d8eb0f85e2 100644 --- a/app/views/users/_tags_form.html.erb +++ b/app/views/users/_tags_form.html.erb @@ -87,255 +87,5 @@ -
- - -
-
- -
- - -
- -
-
-
- > -
-
-
-
- - -
-
-
- - - From a97c134850e18125bd9a74370a1309669e03b0d8 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 6 Jul 2017 19:03:14 -0400 Subject: [PATCH 12/20] Update user.rb --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 91b1c34cc0..5078f3ac9a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,7 +8,7 @@ def validate(record) class User < ActiveRecord::Base self.table_name = 'rusers' - attr_accessible :username, :email, :password, :password_confirmation, :openid_identifier, :key, :photo, :photo_file_name, :location_privacy + attr_accessible :username, :email, :password, :password_confirmation, :openid_identifier, :key, :photo, :photo_file_name, :bio include SolrToggle searchable if: :shouldIndexSolr do From 5bc7cab0d115f759c32c56c8adb488aa68455dcb Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 6 Jul 2017 19:04:18 -0400 Subject: [PATCH 13/20] Update 20170704165711_add_user_bio_and_token.rb --- db/migrate/20170704165711_add_user_bio_and_token.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20170704165711_add_user_bio_and_token.rb b/db/migrate/20170704165711_add_user_bio_and_token.rb index fe790a0399..c7c0dcf876 100644 --- a/db/migrate/20170704165711_add_user_bio_and_token.rb +++ b/db/migrate/20170704165711_add_user_bio_and_token.rb @@ -1,6 +1,6 @@ class AddUserBioAndToken < ActiveRecord::Migration def up - add_column :rusers, :bio, :text, limit: 2147483647 + add_column :rusers, :bio, :text, limit: 2147483647, default: '' add_column :rusers, :token, :string add_column :rusers, :status, :integer, default: 0 remove_column :rusers, :location_privacy @@ -9,7 +9,7 @@ def up DrupalUsers.where('status != 0').each do |u| user = u.user user.status = u.status - user.bio = DrupalProfileValue.find_by_uid(user.id, conditions: { fid: 7 }) + user.bio = DrupalProfileValue.find_by_uid(user.id, conditions: { fid: 7 }) || '' user.token = SecureRandom.uuid user.save({}) end From dab65037680a69c882ee200d8ff6c9b60e770a0a Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 6 Jul 2017 19:05:17 -0400 Subject: [PATCH 14/20] Update schema.rb.example --- db/schema.rb.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb.example b/db/schema.rb.example index ffae3a8847..647d18cf19 100644 --- a/db/schema.rb.example +++ b/db/schema.rb.example @@ -336,7 +336,7 @@ ActiveRecord::Schema.define(:version => 20170704165711) do t.string "photo_file_name" t.string "photo_content_type" t.string "photo_file_size" - t.text "bio", :limit => 2147483647 + t.text "bio", :limit => 2147483647, :default => "" t.string "token" t.integer "status", :default => 0 end From 19e2c16003e9a35f182e381acd3e85a9f999bc33 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 6 Jul 2017 19:26:26 -0400 Subject: [PATCH 15/20] Update profile.html.erb --- app/views/users/profile.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/profile.html.erb b/app/views/users/profile.html.erb index 1c32dd485a..e292a59fef 100644 --- a/app/views/users/profile.html.erb +++ b/app/views/users/profile.html.erb @@ -146,7 +146,7 @@ -

<%= raw auto_link(RDiscount.new(@user.bio).to_html, :sanitize => false) %>

+

<%= raw auto_link(RDiscount.new(@profile_user.bio).to_html, :sanitize => false) %>


From 29b9f35c05e74f659b795046b2b5bcbf53edfd0d Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Fri, 7 Jul 2017 10:34:55 -0400 Subject: [PATCH 16/20] Update user_test.rb --- test/unit/user_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 612660a7e6..bc0de84d14 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -14,6 +14,7 @@ class UserTest < ActiveSupport::TestCase assert_not_nil user.drupal_user assert_not_nil user.uid assert_not_nil user.email + assert_not_nil user.bio end test 'basic user attributes' do From 04ea0ebad1d61a5eac747d7721d9354ec9e20937 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Fri, 7 Jul 2017 16:14:26 -0400 Subject: [PATCH 17/20] Update user.rb --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index 5078f3ac9a..37229ff03f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,6 +42,7 @@ class User < ActiveRecord::Base after_destroy :destroy_drupal_user def create_drupal_user + self.bio = "" # needed to set a default bio value of "" if drupal_user.nil? drupal_user = DrupalUsers.new(name: username, pass: rand(100_000_000_000_000_000_000), From d863e579e4f3d040e81ecc7833ccfc47ac4e3008 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Fri, 7 Jul 2017 16:49:43 -0400 Subject: [PATCH 18/20] Update users.yml --- test/fixtures/users.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index ae9a188479..fd9d630759 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -3,63 +3,74 @@ bob: name: Bob status: 1 mail: bob@publiclab.org + bio: '' jeff: uid: 2 name: jeff status: 1 mail: jeff@pxlshp.com + bio: '' spammer: uid: 3 name: spammer status: 0 #spam mail: spam@spam.com + bio: '' unbanned_spammer: uid: 4 name: unbanned_spammer status: 1 mail: uspam@spam.com + bio: '' admin: uid: 5 name: palpatine status: 1 mail: admin@publiclab.org + bio: '' moderator: uid: 6 name: obiwan status: 1 mail: obiwan@publiclab.org + bio: '' newcomer: uid: 7 name: newcomer status: 1 mail: newcomer@publiclab.org + bio: '' lurker: uid: 8 name: lurker status: 1 mail: lurker@publiclab.org + bio: '' unmoderated_user: uid: 9 name: rob status: 1 mail: rob@publiclab.org + bio: '' test_user: uid: 10 name: testuser status: 1 mail: testuser@publiclab.org + bio: '' legacy_user: uid: 11 name: legacy status: 1 mail: legacy@publiclab.org + bio: '' From 237e5d1db8199c43c2c200238709e87e5a2bdb03 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Fri, 7 Jul 2017 17:55:13 -0400 Subject: [PATCH 19/20] Update users.yml --- test/fixtures/users.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index fd9d630759..ae9a188479 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -3,74 +3,63 @@ bob: name: Bob status: 1 mail: bob@publiclab.org - bio: '' jeff: uid: 2 name: jeff status: 1 mail: jeff@pxlshp.com - bio: '' spammer: uid: 3 name: spammer status: 0 #spam mail: spam@spam.com - bio: '' unbanned_spammer: uid: 4 name: unbanned_spammer status: 1 mail: uspam@spam.com - bio: '' admin: uid: 5 name: palpatine status: 1 mail: admin@publiclab.org - bio: '' moderator: uid: 6 name: obiwan status: 1 mail: obiwan@publiclab.org - bio: '' newcomer: uid: 7 name: newcomer status: 1 mail: newcomer@publiclab.org - bio: '' lurker: uid: 8 name: lurker status: 1 mail: lurker@publiclab.org - bio: '' unmoderated_user: uid: 9 name: rob status: 1 mail: rob@publiclab.org - bio: '' test_user: uid: 10 name: testuser status: 1 mail: testuser@publiclab.org - bio: '' legacy_user: uid: 11 name: legacy status: 1 mail: legacy@publiclab.org - bio: '' From 61ce71770f40b8632418aca08093c90c1ac7154a Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Fri, 7 Jul 2017 17:56:41 -0400 Subject: [PATCH 20/20] Update rusers.yml --- test/fixtures/rusers.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/fixtures/rusers.yml b/test/fixtures/rusers.yml index 82d8c2e1c3..12dad7277c 100644 --- a/test/fixtures/rusers.yml +++ b/test/fixtures/rusers.yml @@ -6,6 +6,8 @@ bob: crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> last_request_at: <%= Time.now %> + bio: '' + token: abcdefg12345 jeff: username: jeff @@ -16,6 +18,7 @@ jeff: crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> last_request_at: <%= Time.now %> + bio: '' spammer: username: spammer @@ -25,6 +28,7 @@ spammer: password_salt: <%= salt = Authlogic::Random.hex_token %> crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> + bio: '' unbanned_spammer: username: unbanned_spammer @@ -34,6 +38,7 @@ unbanned_spammer: password_salt: <%= salt = Authlogic::Random.hex_token %> crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> + bio: '' admin: username: palpatine @@ -44,6 +49,7 @@ admin: crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> role: admin + bio: '' moderator: username: obiwan @@ -54,6 +60,7 @@ moderator: crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> role: moderator + bio: '' newcomer: username: newcomer @@ -64,6 +71,7 @@ newcomer: crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> role: basic + bio: '' lurker: username: lurker @@ -73,6 +81,7 @@ lurker: password_salt: <%= salt = Authlogic::Random.hex_token %> crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> + bio: '' unmoderated_user: username: rob @@ -82,6 +91,7 @@ unmoderated_user: password_salt: <%= salt = Authlogic::Random.hex_token %> crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> + bio: '' test_user: username: testuser @@ -91,3 +101,4 @@ test_user: password_salt: <%= salt = Authlogic::Random.hex_token %> crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("secret" + salt) %> persistence_token: <%= Authlogic::Random.hex_token %> + bio: ''