diff --git a/app/controllers/france_connect/entreprise_controller.rb b/app/controllers/france_connect/entreprise_controller.rb deleted file mode 100644 index bc0754abe..000000000 --- a/app/controllers/france_connect/entreprise_controller.rb +++ /dev/null @@ -1,36 +0,0 @@ -class FranceConnect::EntrepriseController < ApplicationController - def login - client = FranceConnectEntrepriseClient.new - - session[:state] = SecureRandom.hex(16) - session[:nonce] = SecureRandom.hex(16) - - authorization_uri = client.authorization_uri( - scope: [:profile, :email], - state: session[:state], - nonce: session[:nonce] - ) - redirect_to authorization_uri - end - - def callback - return redirect_to new_user_session_path unless params.has_key?(:code) - - user_infos = FranceConnectService.retrieve_user_informations_entreprise(params[:code]) - - unless user_infos.nil? - @user = User.find_for_france_connect(user_infos.email, user_infos.siret) - - sign_in @user - - @user.loged_in_with_france_connect = 'entreprise' - @user.save - - redirect_to stored_location_for(current_user) || signed_in_root_path(current_user) - end - rescue Rack::OAuth2::Client::Error => e - Rails.logger.error e.message - flash.alert = t('errors.messages.france_connect.connexion') - redirect_to(new_user_session_path) - end -end \ No newline at end of file diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml index 330cfd378..af59c8c25 100644 --- a/app/views/users/sessions/new.html.haml +++ b/app/views/users/sessions/new.html.haml @@ -10,7 +10,6 @@ %a.text-info{href: 'https://fcp.integ01.dev-franceconnect.fr/a-propos', target: '_blank'} Qu’est-ce que FranceConnect ? - %hr = form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %h4 diff --git a/config/routes.rb b/config/routes.rb index 3b22f3761..62a1589b3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,9 +16,6 @@ Rails.application.routes.draw do root 'root#index' namespace :france_connect do - # get 'entreprise' => 'entreprise#login' - # get 'entreprise/callback' => 'entreprise#callback' - get 'particulier' => 'particulier#login' get 'particulier/callback' => 'particulier#callback' diff --git a/spec/controllers/france_connect/entreprise_controller_spec.rb b/spec/controllers/france_connect/entreprise_controller_spec.rb deleted file mode 100644 index eb46a9355..000000000 --- a/spec/controllers/france_connect/entreprise_controller_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -# require 'spec_helper' -# -# describe FranceConnect::EntrepriseController, type: :controller do -# -# describe '.login' do -# it 'redirect to france connect serveur' do -# get :login -# expect(response.status).to eq(302) -# end -# end -# -# describe '.callback' do -# context 'when param code is missing' do -# it 'redirect to login page' do -# get :callback -# expect(response).to redirect_to(new_user_session_path) -# end -# end -# context 'when params code is present' do -# let(:code) { 'plop' } -# let(:email) { 'patator@cake.com' } -# let(:siret) { '41123069100049' } -# let(:user_info) { Hashie::Mash.new(email: email, siret: siret) } -# context 'when code is correct' do -# let(:email) { 'patator@cake.com' } -# let(:current_user) { User.find_by_email(email) } -# -# before do -# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_info) -# get :callback, code: code -# end -# -# it 'current user have attribut loged_in_with_france_connect at enterprise' do -# expect(current_user.loged_in_with_france_connect).to eq 'entreprise' -# end -# let(:stored_location) { '/plip/plop' } -# it 'redirect to stored location' do -# subject.store_location_for(:user, stored_location) -# get :callback, code: code -# expect(response).to redirect_to(stored_location) -# end -# end -# -# context 'when code is not correct' do -# before do -# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') } -# get :callback, code: code -# end -# -# it 'redirect to login page' do -# expect(response).to redirect_to(new_user_session_path) -# end -# -# it 'display error message' do -# expect(flash[:alert]).to be_present -# end -# end -# end -# end -# end -# diff --git a/spec/features/france_connect/france_connect_entreprise_spec.rb b/spec/features/france_connect/france_connect_entreprise_spec.rb deleted file mode 100644 index 9a62b77e8..000000000 --- a/spec/features/france_connect/france_connect_entreprise_spec.rb +++ /dev/null @@ -1,81 +0,0 @@ -# require 'spec_helper' -# -# feature 'France Connect Connexion' do -# context 'when user is on login page' do -# -# before do -# visit new_user_session_path -# end -# -# scenario 'link to France Connect is present' do -# expect(page).to have_css('a#btn_fce') -# end -# -# context 'and click on france connect link' do -# let(:code) { 'plop' } -# -# context 'when authentification is ok' do -# before do -# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code)) -# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(Hashie::Mash.new(email: 'patator@cake.com')) -# page.find_by_id('btn_fce').click -# end -# -# scenario 'he is redirected to france connect' do -# expect(page).to have_content('Mes dossiers') -# end -# end -# -# context 'when authentification is not ok' do -# before do -# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code)) -# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') } -# page.find_by_id('btn_fce').click -# end -# -# scenario 'he is redirected to login page' do -# expect(page).to have_css('a#btn_fce') -# end -# -# scenario 'error message is displayed' do -# expect(page).to have_content(I18n.t('errors.messages.france_connect.connexion')) -# end -# end -# end -# end -# -# -# feature 'redirection' do -# before do -# visit initial_path -# end -# context 'when he use france connect' do -# let(:code) { 'my_code' } -# let(:email) { 'plop@plop.com' } -# let(:siret) { '00000000000000' } -# let(:user_infos) { Hashie::Mash.new(email: email, siret: siret) } -# before do -# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code)) -# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_infos) -# page.find_by_id('btn_fce').click -# end -# context 'when starting page is dossiers list' do -# let(:initial_path) { users_dossiers_path } -# scenario 'he is redirected to dossier list' do -# expect(page).to have_css('#users_index') -# end -# end -# context 'when starting page is procedure' do -# let(:procedure) { create(:procedure) } -# let(:initial_path) { new_users_dossiers_path(procedure_id: procedure.id ) } -# scenario 'he is redirected to siret page' do -# expect(page).to have_css('#users_siret_index') -# end -# -# scenario 'the siret is already written in form' do -# expect(page.find_by_id('dossier_siret').value).to have_content(siret) -# end -# end -# end -# end -# end \ No newline at end of file