diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-06-21 02:40:48 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-06-21 02:40:48 +0300 |
commit | d3ff8c1a952b6bee75eac80f4ac61a7b70cb4eb0 (patch) | |
tree | 32f6c427c18d4d654f97917989306433dd0ad5e3 | |
parent | 8304bed105a75b1380b963e5f943de7443105d98 (diff) |
Make default value for otp_required_for_login false instead of null
-rw-r--r-- | app/models/user.rb | 8 | ||||
-rw-r--r-- | db/migrate/20150620233230_add_default_otp_required_for_login_value.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 4 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 4 |
4 files changed, 17 insertions, 8 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 57a36a73ac5..9f1bdb12508 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -50,12 +50,12 @@ # bitbucket_access_token :string(255) # bitbucket_access_token_secret :string(255) # location :string(255) -# public_email :string(255) default(""), not null # encrypted_otp_secret :string(255) # encrypted_otp_secret_iv :string(255) # encrypted_otp_secret_salt :string(255) -# otp_required_for_login :boolean +# otp_required_for_login :boolean default(FALSE), not null # otp_backup_codes :text +# public_email :string(255) default(""), not null # dashboard :integer default(0) # @@ -198,8 +198,8 @@ class User < ActiveRecord::Base scope :active, -> { with_state(:active) } scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all } scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM members)') } - scope :with_two_factor, -> { where('otp_required_for_login IS true') } - scope :without_two_factor, -> { where('otp_required_for_login IS NOT true') } + scope :with_two_factor, -> { where(otp_required_for_login: true) } + scope :without_two_factor, -> { where(otp_required_for_login: false) } # # Class methods diff --git a/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb b/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb new file mode 100644 index 00000000000..c209fa4e80f --- /dev/null +++ b/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb @@ -0,0 +1,9 @@ +class AddDefaultOtpRequiredForLoginValue < ActiveRecord::Migration + def up + change_column :users, :otp_required_for_login, :boolean, default: false, null: false + end + + def down + change_column :users, :otp_required_for_login, :boolean, default: nil + end +end diff --git a/db/schema.rb b/db/schema.rb index f063a4868b1..3a5af6a76d4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150610065936) do +ActiveRecord::Schema.define(version: 20150620233230) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -499,7 +499,7 @@ ActiveRecord::Schema.define(version: 20150610065936) do t.string "encrypted_otp_secret" t.string "encrypted_otp_secret_iv" t.string "encrypted_otp_secret_salt" - t.boolean "otp_required_for_login" + t.boolean "otp_required_for_login", default: false, null: false t.text "otp_backup_codes" t.string "public_email", default: "", null: false t.integer "dashboard", default: 0 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index d86401c9fbb..df7085f1d66 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -50,12 +50,12 @@ # bitbucket_access_token :string(255) # bitbucket_access_token_secret :string(255) # location :string(255) -# public_email :string(255) default(""), not null # encrypted_otp_secret :string(255) # encrypted_otp_secret_iv :string(255) # encrypted_otp_secret_salt :string(255) -# otp_required_for_login :boolean +# otp_required_for_login :boolean default(FALSE), not null # otp_backup_codes :text +# public_email :string(255) default(""), not null # dashboard :integer default(0) # |