diff --git a/app/controllers/users/commencer_controller.rb b/app/controllers/users/commencer_controller.rb index f42c5c31c..a20a009fe 100644 --- a/app/controllers/users/commencer_controller.rb +++ b/app/controllers/users/commencer_controller.rb @@ -34,6 +34,11 @@ module Users redirect_to new_user_registration_path end + def france_connect + store_user_location! + redirect_to france_connect_particulier_path + end + def procedure_for_help Procedure.publiees.find_by(path: params[:path]) || Procedure.brouillons.find_by(path: params[:path]) end diff --git a/app/views/commencer/show.html.haml b/app/views/commencer/show.html.haml index bed41a69f..1f584df63 100644 --- a/app/views/commencer/show.html.haml +++ b/app/views/commencer/show.html.haml @@ -8,6 +8,7 @@ %span.optional-on-small-screens demarches-simplifiees.fr = link_to 'J’ai déjà un compte', commencer_sign_in_path(path: @procedure.path), class: ['button large expand'] + = render partial: 'shared/france_connect_login', locals: { url: commencer_france_connect_path(path: @procedure.path) } - else - dossiers = current_user.dossiers.where(procedure: @procedure) diff --git a/config/routes.rb b/config/routes.rb index 4bab577c4..409795dce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -270,6 +270,7 @@ Rails.application.routes.draw do get '/:path', action: 'commencer' get '/:path/sign_in', action: 'sign_in', as: :sign_in get '/:path/sign_up', action: 'sign_up', as: :sign_up + get '/:path/france_connect', action: 'france_connect', as: :france_connect end resources :dossiers, only: [:index, :show, :new] do diff --git a/spec/controllers/users/commencer_controller_spec.rb b/spec/controllers/users/commencer_controller_spec.rb index cb6e8b069..ae8f2d01a 100644 --- a/spec/controllers/users/commencer_controller_spec.rb +++ b/spec/controllers/users/commencer_controller_spec.rb @@ -112,4 +112,28 @@ describe Users::CommencerController, type: :controller do it { expect(subject).to redirect_to(new_user_registration_path) } end end + + describe '#france_connect' do + context 'for a published procedure' do + subject { get :france_connect, params: { path: published_procedure.path } } + + it 'set the path to return after sign-up to the procedure start page' do + subject + expect(controller.stored_location_for(:user)).to eq(commencer_path(path: published_procedure.path)) + end + + it { expect(subject).to redirect_to(france_connect_particulier_path) } + end + + context 'for a draft procedure' do + subject { get :france_connect, params: { path: draft_procedure.path } } + + it 'set the path to return after sign-up to the draft procedure start page' do + subject + expect(controller.stored_location_for(:user)).to eq(commencer_test_path(path: draft_procedure.path)) + end + + it { expect(subject).to redirect_to(france_connect_particulier_path) } + end + end end diff --git a/spec/views/commencer/show.html.haml_spec.rb b/spec/views/commencer/show.html.haml_spec.rb index b07600502..c8119d7d9 100644 --- a/spec/views/commencer/show.html.haml_spec.rb +++ b/spec/views/commencer/show.html.haml_spec.rb @@ -21,6 +21,7 @@ RSpec.describe 'commencer/show.html.haml', type: :view do subject expect(rendered).to have_link('Créer un compte') expect(rendered).to have_link('J’ai déjà un compte') + expect(rendered).to have_link('S’identifier avec FranceConnect') end end