Merge pull request #6680 from betagouv/fill-both-instructeur-bypass-login-token
This commit is contained in:
commit
84886ac379
6 changed files with 50 additions and 5 deletions
|
@ -1,5 +1,23 @@
|
|||
module Manager
|
||||
class InstructeursController < Manager::ApplicationController
|
||||
# Temporary code: synchronize Flipper's instructeur_bypass_email_login_token
|
||||
# when Instructeur.bypass_email_login_token is modified.
|
||||
#
|
||||
# This will be removed when the migration of this feature flag out of Flipper will be complete.
|
||||
def update
|
||||
super
|
||||
|
||||
instructeur = requested_resource
|
||||
saved_successfully = !requested_resource.changed?
|
||||
if saved_successfully
|
||||
if instructeur.bypass_email_login_token
|
||||
Flipper.enable_actor(:instructeur_bypass_email_login_token, instructeur.user)
|
||||
else
|
||||
Flipper.disable_actor(:instructeur_bypass_email_login_token, instructeur.user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reinvite
|
||||
instructeur = Instructeur.find(params[:id])
|
||||
instructeur.user.invite!
|
||||
|
|
|
@ -14,7 +14,7 @@ class InstructeurDashboard < Administrate::BaseDashboard
|
|||
updated_at: Field::DateTime,
|
||||
dossiers: Field::HasMany,
|
||||
procedures: Field::HasMany,
|
||||
features: FeaturesField
|
||||
bypass_email_login_token: Field::Boolean
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
|
@ -35,13 +35,15 @@ class InstructeurDashboard < Administrate::BaseDashboard
|
|||
:id,
|
||||
:user,
|
||||
:created_at,
|
||||
:features
|
||||
:bypass_email_login_token
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [].freeze
|
||||
FORM_ATTRIBUTES = [
|
||||
:bypass_email_login_token
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how users are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
|
|
|
@ -26,7 +26,7 @@ as well as a link to its edit page.
|
|||
|
||||
<div>
|
||||
<%= link_to(
|
||||
t("administrate.actions.edit_resource", name: page.page_title),
|
||||
'Modifier',
|
||||
[:edit, namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action?(:edit) && show_action?(:edit, page.resource) %>
|
||||
|
|
|
@ -4,3 +4,10 @@ fr:
|
|||
instructeur:
|
||||
one: Instructeur
|
||||
other: Instructeurs
|
||||
attributes:
|
||||
instructeur:
|
||||
bypass_email_login_token: Autoriser la connexion sans confirmer l’email
|
||||
helpers:
|
||||
label:
|
||||
instructeur:
|
||||
bypass_email_login_token: Autoriser la connexion sans confirmer l’email
|
||||
|
|
|
@ -39,7 +39,7 @@ Rails.application.routes.draw do
|
|||
put 'unblock_email'
|
||||
end
|
||||
|
||||
resources :instructeurs, only: [:index, :show] do
|
||||
resources :instructeurs, only: [:index, :show, :edit, :update] do
|
||||
post 'reinvite', on: :member
|
||||
delete 'delete', on: :member
|
||||
end
|
||||
|
|
|
@ -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