From 9c6c6d6f1d90cacb74b8290d5157f5b7aaa1f475 Mon Sep 17 00:00:00 2001 From: Willian Gustavo Veiga Date: Wed, 2 Jun 2021 20:49:10 -0300 Subject: [PATCH] Remove unused login column --- app/models/spree/user.rb | 8 -------- db/default/users.rb | 3 +-- .../20210601202000_remove_login_from_spree_users.rb | 7 +++++++ 3 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20210601202000_remove_login_from_spree_users.rb diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index ab0fd927..8bb54cef 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -26,8 +26,6 @@ def password=(new_password) super end - before_validation :set_login - scope :admin, -> { includes(:spree_roles).where("#{Role.table_name}.name" => "admin") } def self.admin_created? @@ -50,16 +48,10 @@ def password_required? private - def set_login - # for now force login to be same as email, eventually we will make this configurable, etc. - self.login ||= email if email - end - def scramble_email_and_password return true if destroyed? self.email = SecureRandom.uuid + "@example.net" - self.login = email self.password = SecureRandom.hex(8) self.password_confirmation = password save diff --git a/db/default/users.rb b/db/default/users.rb index ea228e06..f8c4c9d9 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -40,8 +40,7 @@ def create_admin_user attributes = { password: password, password_confirmation: password, - email: email, - login: email + email: email } load 'spree/user.rb' diff --git a/db/migrate/20210601202000_remove_login_from_spree_users.rb b/db/migrate/20210601202000_remove_login_from_spree_users.rb new file mode 100644 index 00000000..3f0ef80e --- /dev/null +++ b/db/migrate/20210601202000_remove_login_from_spree_users.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class RemoveLoginFromSpreeUsers < SolidusSupport::Migration[5.1] + def change + remove_column(:spree_users, :login, :string) + end +end