manager: save bypass_email_login_token to both column and feature

This commit is contained in:
Pierre de La Morinerie 2021-11-25 13:44:28 +00:00
parent 8e683977d9
commit 28dfc6a1ba
5 changed files with 32 additions and 5 deletions

View file

@ -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!

View file

@ -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.

View file

@ -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) %>

View file

@ -4,3 +4,10 @@ fr:
instructeur:
one: Instructeur
other: Instructeurs
attributes:
instructeur:
bypass_email_login_token: Autoriser la connexion sans confirmer lemail
helpers:
label:
instructeur:
bypass_email_login_token: Autoriser la connexion sans confirmer lemail

View file

@ -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