SessionController: flipflop trusted device

This commit is contained in:
simon lehericey 2018-11-08 17:14:24 +01:00
parent 36621bffeb
commit fb76197404
6 changed files with 11 additions and 4 deletions

View file

@ -27,7 +27,7 @@ class Users::SessionsController < Sessions::SessionsController
end
if gestionnaire_signed_in?
if trusted_device?
if trusted_device? || !current_gestionnaire.feature_enabled?(:enable_email_login_token)
set_flash_message :notice, :signed_in
redirect_to gestionnaire_procedures_path
else

View file

@ -20,6 +20,7 @@ Flipflop.configure do
feature :web_hook
feature :publish_draft
feature :support_form
feature :enable_email_login_token
group :production do
feature :remote_storage,

View file

@ -27,7 +27,7 @@ describe Users::SessionsController, type: :controller do
let(:password) { 'un super mot de passe' }
let(:user) { create(:user, email: email, password: password) }
let(:gestionnaire) { create(:gestionnaire, email: email, password: password) }
let(:gestionnaire) { create(:gestionnaire, :with_trusted_device, email: email, password: password) }
let(:administrateur) { create(:administrateur, email: email, password: password) }
it 'signs user in' do

View file

@ -4,4 +4,10 @@ FactoryBot.define do
email { generate(:gestionnaire_email) }
password { 'password' }
end
trait :with_trusted_device do
after(:create) do |gestionnaire|
gestionnaire.update(features: { "enable_email_login_token" => true })
end
end
end

View file

@ -6,7 +6,7 @@ feature 'Administrator connection' do
let(:email) { 'admin1@admin.com' }
let(:password) { 'mon chien aime les bananes' }
let!(:admin) { create(:administrateur, email: email, password: password) }
let!(:gestionnaire) { create(:gestionnaire, email: email, password: password) }
let!(:gestionnaire) { create(:gestionnaire, :with_trusted_device, email: email, password: password) }
before do
visit new_administrateur_session_path

View file

@ -4,7 +4,7 @@ feature 'The gestionnaire part' do
include ActiveJob::TestHelper
let(:password) { 'secret_password' }
let!(:gestionnaire) { create(:gestionnaire, password: password) }
let!(:gestionnaire) { create(:gestionnaire, :with_trusted_device, password: password) }
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }