amelioration(instructeur#activate_account): passage de la page de d'activation d'un compte instructeur au dsfr

This commit is contained in:
Martin 2023-08-30 10:44:59 +02:00 committed by mfo
parent 62e5b1426a
commit 26045cdd5f
10 changed files with 61 additions and 10 deletions

View file

@ -0,0 +1,6 @@
class Instructeurs::ActivateAccountFormComponent < ApplicationComponent
attr_reader :user
def initialize(user:)
@user = user
end
end

View file

@ -0,0 +1,6 @@
---
en:
title: Create your account for %{application_name}
activate: Activate your account %{email}
email_disabled: Instructor email address not changeable
submit: Choose password

View file

@ -0,0 +1,7 @@
---
fr:
title: Création de compte sur %{application_name}
activate: Se créer un compte pour %{email} en choissant un mot de passe
email_disabled: Adresse instructeur non modifiable
submit: Définir le mot de passe

View file

@ -0,0 +1,23 @@
= form_for user, url: { controller: 'users/activate', action: :create }, html: { class: "fr-py-5w" } do |f|
%h1.fr-h2.fr-mb-7w= t('.title', application_name: APPLICATION_NAME)
.fr-background-alt--grey.fr-px-12w.fr-py-7w
%fieldset.fr-mb-0.fr-fieldset{ aria: { labelledby: 'activate-account-legend' } }
%legend.fr-fieldset__legend#activate-account-legend
%h2.fr-h6.fr-mb-0= t('.activate', email: user.email)
.fr-fieldset__element
%p.fr-text--sm= t('utils.mandatory_champs')
.fr-fieldset__element= render Dsfr::InputComponent.new(form: f, attribute: :email, input_type: :email_field, opts: { disabled: :disabled, class: 'fr-input-group--disabled', value: t('.email_disabled') })
.fr-fieldset__element= render Dsfr::InputComponent.new(form: f, attribute: :password, input_type: :password_field, opts: { autocomplete: 'current-password' })
= f.hidden_field :reset_password_token, value: params[:token]
.fr-fieldset__element
.fr-btns-group--right.fr-btns-group.fr-btns-group--inline.fr-btns-group.fr-btns-group--inline
%ul
%li= f.submit t('.submit'), class: 'fr-mt-2v fr-btn fr-btn'

View file

@ -19,8 +19,9 @@ class Users::SessionsController < Devise::SessionsController
end
def reset_link_sent
send_login_token_or_bufferize(current_instructeur)
flash[:notice] = "Nous venons de vous renvoyer un nouveau lien de connexion sécurisée à #{APPLICATION_NAME}"
if send_login_token_or_bufferize(current_instructeur)
flash[:notice] = "Nous venons de vous renvoyer un nouveau lien de connexion sécurisée à #{APPLICATION_NAME}"
end
redirect_to link_sent_path(email: current_instructeur.email)
end

View file

@ -21,6 +21,9 @@ module TrustedDeviceConcern
if !instructeur.young_login_token?
token = instructeur.create_trusted_device_token
InstructeurMailer.send_login_token(instructeur, token).deliver_later
true
else
false
end
end

View file

@ -1,7 +1,9 @@
.container
= form_for @user, url: { controller: 'users/activate', action: :create }, html: { class: "form" } do |f|
%br
%h1= @user.email
= f.password_field :password, placeholder: 'Mot de passe'
= f.hidden_field :reset_password_token, value: params[:token]
= f.submit 'Définir le mot de passe', class: 'button large primary expand'
= content_for(:page_id, 'activate_account')
= content_for(:title, t('metas.users.activate.title', application_name: APPLICATION_NAME))
.fr-container.fr-my-5w
.fr-grid-row
.fr-col-12.fr-col-offset-md-2.fr-col-md-8
= render Instructeurs::ActivateAccountFormComponent.new(user: @user)
= render partial: 'users/dossiers/index_footer'

View file

@ -1,7 +1,6 @@
= content_for(:page_id, 'auth')
= content_for(:title, t('metas.signin.title'))
#session-new.auth-form.sign-in-form
= form_for resource, url: user_session_path, html: { class: "fr-py-5w" } do |f|

View file

@ -17,3 +17,5 @@ en:
title: "Modification of draft nº %{number} (%{procedure_label})"
merci:
title: "File submitted (%{procedure_label})"
activate:
title: Activate my account on %{application_name}

View file

@ -17,3 +17,5 @@ fr:
title: "Modification du brouillon nº %{number} (%{procedure_label})"
merci:
title: "Dossier envoyé (%{procedure_label})"
activate:
title: Activer mon compte sur %{application_name}