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:
commit
d4d08cc5d5
11 changed files with 75 additions and 46 deletions
|
@ -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;
|
||||||
|
|
28
app/assets/stylesheets/new_design/france-connect-login.scss
Normal file
28
app/assets/stylesheets/new_design/france-connect-login.scss
Normal 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;
|
||||||
|
}
|
|
@ -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
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
%span.optional-on-small-screens
|
%span.optional-on-small-screens
|
||||||
demarches-simplifiees.fr
|
demarches-simplifiees.fr
|
||||||
= link_to 'J’ai déjà un compte', commencer_sign_in_path(path: @procedure.path), class: ['button large expand']
|
= 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
|
- else
|
||||||
- dossiers = current_user.dossiers.where(procedure: @procedure)
|
- dossiers = current_user.dossiers.where(procedure: @procedure)
|
||||||
|
|
7
app/views/shared/_france_connect_login.html.haml
Normal file
7
app/views/shared/_france_connect_login.html.haml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
.france-connect-login
|
||||||
|
.france-connect-login-separator
|
||||||
|
ou
|
||||||
|
.france-connect-login-buttons
|
||||||
|
= link_to "S’identifier avec FranceConnect", url, class: "france-connect-login-button"
|
||||||
|
.france-connect-help-link
|
||||||
|
= link_to "Qu’est-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link"
|
|
@ -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 "Qu’est-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link"
|
|
||||||
|
|
|
@ -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 "Qu’est-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", rel: "noopener", class: "link"
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature 'France Connect Particulier Connexion' do
|
feature 'France Connect Particulier Connexion' do
|
||||||
let(:code) { 'plop' }
|
let(:code) { 'plop' }
|
||||||
let(:given_name) { 'titi' }
|
let(:given_name) { 'titi' }
|
||||||
let(:family_name) { 'toto' }
|
let(:family_name) { 'toto' }
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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('J’ai déjà un compte')
|
expect(rendered).to have_link('J’ai déjà un compte')
|
||||||
|
expect(rendered).to have_link('S’identifier avec FranceConnect')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue