manager: save bypass_email_login_token to both column and feature
This commit is contained in:
parent
8e683977d9
commit
28dfc6a1ba
5 changed files with 32 additions and 5 deletions
|
@ -1,5 +1,23 @@
|
||||||
module Manager
|
module Manager
|
||||||
class InstructeursController < Manager::ApplicationController
|
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
|
def reinvite
|
||||||
instructeur = Instructeur.find(params[:id])
|
instructeur = Instructeur.find(params[:id])
|
||||||
instructeur.user.invite!
|
instructeur.user.invite!
|
||||||
|
|
|
@ -14,7 +14,7 @@ class InstructeurDashboard < Administrate::BaseDashboard
|
||||||
updated_at: Field::DateTime,
|
updated_at: Field::DateTime,
|
||||||
dossiers: Field::HasMany,
|
dossiers: Field::HasMany,
|
||||||
procedures: Field::HasMany,
|
procedures: Field::HasMany,
|
||||||
features: FeaturesField
|
bypass_email_login_token: Field::Boolean
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# COLLECTION_ATTRIBUTES
|
# COLLECTION_ATTRIBUTES
|
||||||
|
@ -35,13 +35,15 @@ class InstructeurDashboard < Administrate::BaseDashboard
|
||||||
:id,
|
:id,
|
||||||
:user,
|
:user,
|
||||||
:created_at,
|
:created_at,
|
||||||
:features
|
:bypass_email_login_token
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# FORM_ATTRIBUTES
|
# FORM_ATTRIBUTES
|
||||||
# an array of attributes that will be displayed
|
# an array of attributes that will be displayed
|
||||||
# on the model's form (`new` and `edit`) pages.
|
# 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
|
# Overwrite this method to customize how users are displayed
|
||||||
# across all pages of the admin dashboard.
|
# across all pages of the admin dashboard.
|
||||||
|
|
|
@ -26,7 +26,7 @@ as well as a link to its edit page.
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= link_to(
|
<%= link_to(
|
||||||
t("administrate.actions.edit_resource", name: page.page_title),
|
'Modifier',
|
||||||
[:edit, namespace, page.resource],
|
[:edit, namespace, page.resource],
|
||||||
class: "button",
|
class: "button",
|
||||||
) if valid_action?(:edit) && show_action?(:edit, page.resource) %>
|
) if valid_action?(:edit) && show_action?(:edit, page.resource) %>
|
||||||
|
|
|
@ -4,3 +4,10 @@ fr:
|
||||||
instructeur:
|
instructeur:
|
||||||
one: Instructeur
|
one: Instructeur
|
||||||
other: Instructeurs
|
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'
|
put 'unblock_email'
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :instructeurs, only: [:index, :show] do
|
resources :instructeurs, only: [:index, :show, :edit, :update] do
|
||||||
post 'reinvite', on: :member
|
post 'reinvite', on: :member
|
||||||
delete 'delete', on: :member
|
delete 'delete', on: :member
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue