Skip to content

Commit

Permalink
[Backport] - FranceConnect Logout Modifications (#15)
Browse files Browse the repository at this point in the history
* Update FC images

* Update partials and views to make the button appear correctly everywhere

* Normalize locales and add missing ones from FranceConnect

* Update FranceConnect gem version

* Extend this new file to disconnect from FC while deleting account from platform

* Same but for the logout

* Modify initializer of FranceConnect

* Rubocop Changes
  • Loading branch information
AyakorK authored Mar 17, 2023
1 parent 9e3e21c commit 6a6f7d8
Show file tree
Hide file tree
Showing 14 changed files with 296 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GIT

GIT
remote: https://github.com/OpenSourcePolitics/omniauth-france_connect
revision: 4665875c94d45a71dac163889e0eedd21b2ba41d
revision: 14a53ad31928c8a83742360cfbdb90938d0a057e
specs:
omniauth-france_connect (0.1.0)
omniauth_openid_connect (~> 0.4.0)
Expand Down
4 changes: 4 additions & 0 deletions OVERLOADS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Overrides

## Update France Connect with requirements
* `app/views/decidim/devise/passwords/new.html.erb`
* `app/views/decidim/shared/_login_modal.html.erb`

## Load decidim-awesome assets only if dependencie is present
* `app/views/layouts/decidim/_head.html.erb:33`

Expand Down
Binary file modified app/packs/images/FCboutons-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/packs/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions app/views/decidim/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<% add_decidim_page_title(t("devise.passwords.new.forgot_your_password")) %>

<div class="wrapper">
<div class="row collapse">
<div class="row collapse">
<div class="columns large-8 large-centered text-center page-title">
<h1><%= t("devise.passwords.new.forgot_your_password") %></h1>
</div>
</div>

<div class="row">
<div class="columns medium-7 large-5 medium-centered">
<div class="card">
<div class="card__content">
<%= decidim_form_for(resource, namespace: "password", as: resource_name, url: password_path(resource_name), html: { method: :post, class: "register-form new_user" }) do |f| %>
<div class="field">
<%= f.email_field :email, autofocus: true %>
</div>

<% if current_organization.enabled_omniauth_providers.keys.any? { |provider| provider.match?("france") } %>
<div class="help-text ok-text">
<p><%= t("decidim.omniauth.france_connect.forgot_password.ok_text") %></p>
</div>
<% end %>

<div class="actions">
<%= f.submit t("devise.passwords.new.send_me_reset_password_instructions"), class: "button expanded" %>
</div>

<% end %>
<%= render "decidim/devise/shared/links" %>
</div>
</div>
</div>
</div>
</div>
</div>
25 changes: 15 additions & 10 deletions app/views/decidim/devise/shared/_omniauth_buttons.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
<% if Devise.mappings[:user].omniauthable? && current_organization.enabled_omniauth_providers.any? %>
<div class="row">
<div class="columns large-4 mediumlarge-6 medium-8 medium-centered">
<div class="columns mediumlarge-6 medium-centered">
<%- current_organization.enabled_omniauth_providers.keys.each do |provider| %>
<div class="social-register">
<% if provider.match?("france") %>
<span class="register__separator">
<span class="register__separator__text"><%= t("devise.shared.links.sign_in_with_provider", provider: normalize_full_provider_name(provider).titleize) %></span>
</span>
<div class="text-center">
<%= sso_provider_image(provider, decidim.send("user_#{provider}_omniauth_authorize_path")) %>
</div>
<% if I18n.exists?("decidim.omniauth.france_connect.external.link") %>
<div class="text-center">
<%= link_to t("link", scope: "decidim.omniauth.france_connect.external"), class: "primary", target: "_blank" do %>
<small >
<%= t("text", scope: "decidim.omniauth.france_connect.external") %>
</small>
<% end %>
</div>
<% end %>
<% else %>
<div class="social-register__provider medium-centered">
<%== sso_provider_button(provider, decidim.send("user_#{provider}_omniauth_authorize_path")).html_safe %>
<% end %>

<% if I18n.exists?("decidim.omniauth.france_connect.external.link") %>
<%= link_to t("link", scope: "decidim.omniauth.france_connect.external"), class: "primary", target: "_blank" do %>
<small>
<%= t("text", scope: "decidim.omniauth.france_connect.external") %>
</small>
<% end %>
</div>
<% end %>
</div>
<% end %>
Expand All @@ -28,4 +33,4 @@
<%- end %>
</div>
</div>
<% end %>
<% end %>
60 changes: 60 additions & 0 deletions app/views/decidim/shared/_login_modal.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<div class="reveal" id="loginModal" data-reveal role="dialog" aria-modal="true" aria-labelledby="loginModal-label">
<div class="reveal__header">
<h2 id="loginModal-label" class="reveal__title"><%= t(".please_sign_in") %></h2>
<button class="close-button" data-close aria-label="<%= t(".close_modal") %>"
type="button">
<span aria-hidden="true">&times;</span>
</button>
</div>
<% if current_organization.sign_in_enabled? %>
<div class="border-t-2 border-background">
<% cache current_organization do %>
<%= render "decidim/devise/shared/omniauth_buttons" %>
<% end %>
</div>
<div class="row">
<div class="columns medium-8 medium-centered">
<%
path = if content_for(:redirect_after_login)
session_path(:user, redirect_url: content_for(:redirect_after_login))
else
session_path(:user)
end
%>
<%= decidim_form_for(Decidim::User.new, namespace: "login", as: :user, url: path, html: { class: "register-form new_user" }) do |f| %>
<div>
<div class="field">
<%= f.email_field :email %>
</div>
<div class="field">
<%= f.password_field :password, autocomplete: "off" %>
</div>
</div>
<div class="actions">
<%= f.submit t("devise.sessions.new.sign_in"), class: "button expanded" %>
</div>
<% end %>
<% if current_organization.sign_up_enabled? %>
<p class="text-center">
<%= link_to t(".sign_up"), decidim.new_user_registration_path, class: "sign-up-link" %>
</p>
<% end %>
<p class="text-center">
<%= link_to t("devise.shared.links.forgot_your_password"), new_password_path(:user) %>
</p>
</div>
</div>

<% else %>
<div class="row">
<div class="columns medium-8 medium-centered">
<p>
<%= t("sign_in_disabled", scope: "decidim.devise.sessions.new") %>
</p>
</div>
</div>
<% cache current_organization do %>
<%= render "decidim/devise/shared/omniauth_buttons" %>
<% end %>
<% end %>
</div>
1 change: 1 addition & 0 deletions config/initializers/extends.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

require "extends/controllers/decidim/devise/sessions_controller_extends"
require "extends/queries/decidim/participatory_processes/group_participatory_processes_extends"
require "extends/controllers/decidim/devise/account_controller_extends"
28 changes: 13 additions & 15 deletions config/initializers/omniauth_france_connect.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# frozen_string_literal: true

if Rails.application.secrets.dig(:omniauth, :france_connect).present?
Rails.application.config.middleware.use OmniAuth::Builder do
provider(
:france_connect,
setup: lambda { |env|
request = Rack::Request.new(env)
organization = Decidim::Organization.find_by(host: request.host)
provider_config = organization.enabled_omniauth_providers[:france_connect]
env["omniauth.strategy"].options[:client_id] = provider_config[:client_id]
env["omniauth.strategy"].options[:client_secret] = provider_config[:client_secret]
env["omniauth.strategy"].options[:site] = provider_config[:site_url]
env["omniauth.strategy"].options[:scope] = provider_config[:scope]&.split(" ")
}
)
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider(
:france_connect,
setup: lambda { |env|
request = Rack::Request.new(env)
organization = env["decidim.current_organization"].presence || Decidim::Organization.find_by(host: request.host)
provider_config = organization.enabled_omniauth_providers[:france_connect]
env["omniauth.strategy"].options[:client_id] = provider_config[:client_id]
env["omniauth.strategy"].options[:client_secret] = provider_config[:client_secret]
env["omniauth.strategy"].options[:site] = provider_config[:site_url]
env["omniauth.strategy"].options[:scope] = provider_config[:scope]&.split(" ")
}
)
end
40 changes: 31 additions & 9 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ en:
participatory_process:
private_space: Private space
decidim:
omniauth:
france_connect:
external:
link: https://franceconnect.gouv.fr/
text: Qu'est-ce-que FranceConnect ?
accessibility:
skip_button: Skip button
admin:
Expand All @@ -37,6 +32,10 @@ en:
name: Identity Verification Form
osp_authorization_workflow:
name: Authorization procedure
devise:
sessions:
new:
sign_in_disabled: Sign in disabled
events:
budgets:
pending_order:
Expand All @@ -57,11 +56,7 @@ en:
email_subject: Failed verification attempt against a managed participant
notification_title: The participant <a href="%{resource_path}">%{resource_title}</a> has tried to verify themself with the data of the managed participant <a href="%{managed_user_path}">%{managed_user_name}</a>.
newsletter_templates:
mel_template_settings_form:
interpolations_hint: Interpolations hint
body: Body
mel_template:
name: Template
alt_banner_image: Alt banner image
mel_template_settings_form:
show:
Expand All @@ -79,6 +74,17 @@ en:
icon: Icon
link: Link
text: Text
name: Template
mel_template_settings_form:
body: Body
interpolations_hint: Interpolations hint
omniauth:
france_connect:
external:
link: https://franceconnect.gouv.fr/
text: What is FranceConnect ?
forgot_password:
ok_text: Warning, this password is the one of your local account and in no case the one of the account you use through FranceConnect. It will only be used when you log in with your email address rather than via FranceConnect.
proposals:
create:
error: There was a problem saving
Expand All @@ -101,6 +107,11 @@ en:
withdraw:
errors:
has_supports: This proposal can not be withdrawn because it already has supports.
shared:
login_modal:
close_modal: Fermer
please_sign_in: Veuillez vous connecter
sign_up: Créer un compte
system:
organizations:
omniauth_settings:
Expand Down Expand Up @@ -133,6 +144,17 @@ en:
actions:
osp_authorization_handler: Verify with the identity verification form
osp_authorization_workflow: Verify with the identity verification form
devise:
passwords:
new:
forgot_your_password: Forgot your password
send_me_reset_password_instructions: Send me reset password instructions
sessions:
new:
sign_in: Log in
shared:
links:
forgot_your_password: Forgot your password
faker:
address:
country_code:
Expand Down
34 changes: 28 additions & 6 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ fr:
participatory_process:
private_space: Espace privé
decidim:
omniauth:
france_connect:
external:
link: https://franceconnect.gouv.fr/
text: Qu'est-ce-que FranceConnect ?
accessibility:
skip_button: Passer au contenu principal
admin:
Expand All @@ -37,6 +32,10 @@ fr:
name: Formulaire de vérification d'identité
osp_authorization_workflow:
name: Procédure d'autorisation
devise:
sessions:
new:
sign_in_disabled: Vous pouvez accéder avec un compte externe
events:
budgets:
pending_order:
Expand Down Expand Up @@ -77,6 +76,13 @@ fr:
show:
body: Contenu principal
interpolations_hint: Interpolation
omniauth:
france_connect:
external:
link: https://franceconnect.gouv.fr/
text: Qu'est-ce-que FranceConnect ?
forgot_password:
ok_text: Warning, this password is the one of your local account and in no case the one of the account you use through FranceConnect. It will only be used when you log in with your email address rather than via FranceConnect.
proposals:
create:
error: Il y a eu des erreurs lors de la sauvegarde de la proposition.
Expand All @@ -99,15 +105,20 @@ fr:
withdraw:
errors:
has_supports: Cette proposition ne peut pas être retirée car elle dispose déjà de supports.
shared:
login_modal:
close_modal: Close modal
please_sign_in: Please sign in
sign_up: Sign up
system:
organizations:
omniauth_settings:
france_connect:
client_id: Client ID
client_secret: Client secret
scope: Périmètre de données
provider: FranceConnect
provider_name: FranceConnect
scope: Périmètre de données
site_url: Site URL
france_connect_profile:
button_path: Chemin du bouton
Expand All @@ -131,6 +142,17 @@ fr:
actions:
osp_authorization_handler: Vérifier avec le formulaire de vérification de l'identité
osp_authorization_workflow: Vérifier avec le formulaire de vérification de l'identité
devise:
passwords:
new:
forgot_your_password: Mot de passe oublié ?
send_me_reset_password_instructions: Envoyez-moi les instructions de réinitialisation du mot de passe
sessions:
new:
sign_in: S'identifier
shared:
links:
forgot_your_password: Mot de passe oublié ?
faker:
address:
country_code:
Expand Down
Loading

0 comments on commit 6a6f7d8

Please sign in to comment.