Merge pull request #3727 from betagouv/login-with-fc

Proposer le login FranceConnect sur la page de garde des démarches
This commit is contained in:
Mathieu Magnin 2019-04-03 16:49:37 +02:00 committed by GitHub
commit d4d08cc5d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 75 additions and 46 deletions

View file

@ -15,28 +15,6 @@
margin-bottom: 0; margin-bottom: 0;
} }
.separation {
font-size: 14px;
color: $grey;
margin: 24px 0;
}
.login-with-fc {
display: inline-block;
height: 52px;
width: 186px;
margin: auto;
margin-bottom: 8px;
background-image: image-url("login-with-fc.svg");
background-repeat: no-repeat;
background-size: cover;
cursor: pointer;
&:hover {
background-image: image-url("login-with-fc-hover.svg");
}
}
hr { hr {
margin-top: 30px; margin-top: 30px;
margin-bottom: 30px; margin-bottom: 30px;

View file

@ -0,0 +1,28 @@
@import "colors";
.france-connect-login {
text-align: center;
}
.france-connect-login-button {
display: inline-block;
height: 52px;
width: 186px;
margin: auto;
margin-bottom: 8px;
background-image: image-url("login-with-fc.svg"), image-url("login-with-fc-hover.svg");
background-repeat: no-repeat;
background-size: cover;
cursor: pointer;
font-size: 0;
&:hover {
background-image: image-url("login-with-fc-hover.svg");
}
}
.france-connect-login-separator {
margin: 24px 0;
font-size: 14px;
color: $grey;
}

View file

@ -34,6 +34,11 @@ module Users
redirect_to new_user_registration_path redirect_to new_user_registration_path
end end
def france_connect
store_user_location!
redirect_to france_connect_particulier_path
end
def procedure_for_help def procedure_for_help
Procedure.publiees.find_by(path: params[:path]) || Procedure.brouillons.find_by(path: params[:path]) Procedure.publiees.find_by(path: params[:path]) || Procedure.brouillons.find_by(path: params[:path])
end end

View file

@ -8,6 +8,7 @@
%span.optional-on-small-screens %span.optional-on-small-screens
demarches-simplifiees.fr demarches-simplifiees.fr
= link_to 'Jai déjà un compte', commencer_sign_in_path(path: @procedure.path), class: ['button large expand'] = link_to 'Jai 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 - else
- dossiers = current_user.dossiers.where(procedure: @procedure) - dossiers = current_user.dossiers.where(procedure: @procedure)

View file

@ -0,0 +1,7 @@
.france-connect-login
.france-connect-login-separator
ou
.france-connect-login-buttons
= link_to "Sidentifier avec FranceConnect", url, class: "france-connect-login-button"
.france-connect-help-link
= link_to "Quest-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link"

View file

@ -11,12 +11,4 @@
= f.submit "Créer un compte", class: "button large primary expand" = f.submit "Créer un compte", class: "button large primary expand"
.separation.center = render partial: 'shared/france_connect_login', locals: { url: france_connect_particulier_path }
ou
.center
= image_tag "login-with-fc-hover.svg", style: "display: none"
= link_to "", france_connect_particulier_path, class: "login-with-fc"
.center
= link_to "Quest-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link"

View file

@ -28,12 +28,4 @@
= f.submit "Se connecter", class: "button large primary expand" = f.submit "Se connecter", class: "button large primary expand"
.separation.center = render partial: 'shared/france_connect_login', locals: { url: france_connect_particulier_path }
ou
.center
= image_tag "login-with-fc-hover.svg", style: "display: none"
= link_to "", france_connect_particulier_path, class: "login-with-fc"
.center
= link_to "Quest-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link"

View file

@ -270,6 +270,7 @@ Rails.application.routes.draw do
get '/:path', action: 'commencer' get '/:path', action: 'commencer'
get '/:path/sign_in', action: 'sign_in', as: :sign_in get '/:path/sign_in', action: 'sign_in', as: :sign_in
get '/:path/sign_up', action: 'sign_up', as: :sign_up get '/:path/sign_up', action: 'sign_up', as: :sign_up
get '/:path/france_connect', action: 'france_connect', as: :france_connect
end end
resources :dossiers, only: [:index, :show, :new] do resources :dossiers, only: [:index, :show, :new] do

View file

@ -112,4 +112,28 @@ describe Users::CommencerController, type: :controller do
it { expect(subject).to redirect_to(new_user_registration_path) } it { expect(subject).to redirect_to(new_user_registration_path) }
end end
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 end

View file

@ -28,7 +28,7 @@ feature 'France Connect Particulier Connexion' do
end end
scenario 'link to France Connect is present' do scenario 'link to France Connect is present' do
expect(page).to have_css('a.login-with-fc') expect(page).to have_css('.france-connect-login-button')
end end
context 'and click on france connect link' do context 'and click on france connect link' do
@ -53,7 +53,7 @@ feature 'France Connect Particulier Connexion' do
context 'when is the first connexion' do context 'when is the first connexion' do
before do before do
page.find('.login-with-fc').click page.find('.france-connect-login-button').click
end end
scenario 'he is redirected to user dossiers page' do scenario 'he is redirected to user dossiers page' do
@ -64,7 +64,7 @@ feature 'France Connect Particulier Connexion' do
context 'when is not the first connexion' do context 'when is not the first connexion' do
before do before do
create(:user, france_connect_information: france_connect_information) create(:user, france_connect_information: france_connect_information)
page.find('.login-with-fc').click page.find('.france-connect-login-button').click
end end
scenario 'he is redirected to user dossiers page' do scenario 'he is redirected to user dossiers page' do
@ -77,11 +77,11 @@ feature 'France Connect Particulier Connexion' do
before do before do
allow_any_instance_of(FranceConnectParticulierClient).to receive(:authorization_uri).and_return(france_connect_particulier_callback_path(code: code)) allow_any_instance_of(FranceConnectParticulierClient).to receive(:authorization_uri).and_return(france_connect_particulier_callback_path(code: code))
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') } allow(FranceConnectService).to receive(:retrieve_user_informations_particulier) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
page.find('.login-with-fc').click page.find('.france-connect-login-button').click
end end
scenario 'he is redirected to login page' do scenario 'he is redirected to login page' do
expect(page).to have_css('a.login-with-fc') expect(page).to have_css('.france-connect-login-button')
end end
scenario 'error message is displayed' do scenario 'error message is displayed' do

View file

@ -21,6 +21,7 @@ RSpec.describe 'commencer/show.html.haml', type: :view do
subject subject
expect(rendered).to have_link('Créer un compte') expect(rendered).to have_link('Créer un compte')
expect(rendered).to have_link('Jai déjà un compte') expect(rendered).to have_link('Jai déjà un compte')
expect(rendered).to have_link('Sidentifier avec FranceConnect')
end end
end end