Remplacement de la feature Flipper instructeur_bypass_email_login_token 3/3 (#6681)
This commit is contained in:
commit
9ae4361f59
8 changed files with 7 additions and 28 deletions
|
@ -224,7 +224,7 @@ class ApplicationController < ActionController::Base
|
|||
def redirect_if_untrusted
|
||||
if instructeur_signed_in? &&
|
||||
sensitive_path &&
|
||||
!feature_enabled?(:instructeur_bypass_email_login_token) &&
|
||||
!current_instructeur.bypass_email_login_token &&
|
||||
!IPService.ip_trusted?(request.headers['X-Forwarded-For']) &&
|
||||
!trusted_device?
|
||||
|
||||
|
|
|
@ -1,23 +1,5 @@
|
|||
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!
|
||||
|
|
|
@ -63,8 +63,8 @@ module TPS
|
|||
end
|
||||
|
||||
config.middleware.use Rack::Attack
|
||||
config.middleware.use Flipper::Middleware::Memoizer,
|
||||
preload: [:instructeur_bypass_email_login_token]
|
||||
# Ensure we make maximum one call per feature per request.
|
||||
config.middleware.use Flipper::Middleware::Memoizer
|
||||
|
||||
config.ds_env = ENV.fetch('DS_ENV', Rails.env)
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ features = [
|
|||
:dossier_pdf_vide,
|
||||
:expert_not_allowed_to_invite,
|
||||
:hide_instructeur_email,
|
||||
:instructeur_bypass_email_login_token,
|
||||
:procedure_revisions,
|
||||
:procedure_routage_api,
|
||||
:procedure_process_expired_dossiers_termine
|
||||
|
|
|
@ -165,7 +165,7 @@ describe ApplicationController, type: :controller do
|
|||
let(:sensitive_path) { true }
|
||||
|
||||
before do
|
||||
Flipper.disable(:instructeur_bypass_email_login_token)
|
||||
current_instructeur.update!(bypass_email_login_token: false)
|
||||
end
|
||||
|
||||
context 'when the instructeur is signed_in' do
|
||||
|
|
|
@ -2,6 +2,8 @@ FactoryBot.define do
|
|||
sequence(:instructeur_email) { |n| "inst#{n}@inst.com" }
|
||||
|
||||
factory :instructeur do
|
||||
bypass_email_login_token { true }
|
||||
|
||||
user { association :user, email: email, password: password }
|
||||
|
||||
transient do
|
||||
|
|
|
@ -89,10 +89,6 @@ RSpec.configure do |config|
|
|||
Geocoder.configure(lookup: :test)
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
Flipper.enable(:instructeur_bypass_email_login_token)
|
||||
end
|
||||
|
||||
# By default, forgery protection is disabled in the test environment.
|
||||
# (See `config.action_controller.allow_forgery_protection` in `config/test.rb`)
|
||||
#
|
||||
|
|
|
@ -17,7 +17,7 @@ module SystemHelpers
|
|||
fill_in :user_password, with: password
|
||||
|
||||
if sign_in_by_link
|
||||
Flipper.disable(:instructeur_bypass_email_login_token)
|
||||
User.find_by(email: email)&.instructeur&.update!(bypass_email_login_token: false)
|
||||
end
|
||||
|
||||
perform_enqueued_jobs do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue