Merge pull request #6082 from betagouv/do_not_use_flipper_for_bypass_email_login
n'utilise plus flipper pour passer outre le login par jeton (1er partie)
This commit is contained in:
commit
89f1cff796
4 changed files with 32 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
|||
# Table name: instructeurs
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# bypass_email_login_token :boolean default(FALSE), not null
|
||||
# encrypted_login_token :text
|
||||
# login_token_created_at :datetime
|
||||
# created_at :datetime
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddBypassEmailLoginTokenColumnToInstructeur < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
# This may take a while if running on Postgres < 11
|
||||
add_column :instructeurs, :bypass_email_login_token, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_04_09_075105) do
|
||||
ActiveRecord::Schema.define(version: 2021_04_09_130604) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -459,6 +459,7 @@ ActiveRecord::Schema.define(version: 2021_04_09_075105) do
|
|||
t.datetime "updated_at"
|
||||
t.text "encrypted_login_token"
|
||||
t.datetime "login_token_created_at"
|
||||
t.boolean "bypass_email_login_token", default: false, null: false
|
||||
end
|
||||
|
||||
create_table "invites", id: :serial, force: :cascade do |t|
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: populate_bypass_email_login'
|
||||
task populate_bypass_email_login: :environment do
|
||||
user_ids = Flipper::Adapters::ActiveRecord::Gate
|
||||
.where(feature_key: 'instructeur_bypass_email_login_token')
|
||||
.pluck(:value)
|
||||
.filter { |s| s.start_with?('User:') }
|
||||
.map { |s| s.gsub('User:', '') }
|
||||
.map(&:to_i)
|
||||
|
||||
Instructeur
|
||||
.where(user: { id: user_ids })
|
||||
.update_all(bypass_email_login_token: true)
|
||||
|
||||
AfterParty::TaskRecord
|
||||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue