Merge pull request #11125 from demarches-simplifiees/post_password_in_complexity_test

Tech: vérifie la complexité avec un post
This commit is contained in:
LeSim 2024-12-09 10:53:09 +00:00 committed by GitHub
commit 438bf21d18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 45 additions and 9 deletions

View file

@ -16,7 +16,12 @@
.fr-fieldset__element
= render Dsfr::InputComponent.new(form: f, attribute: :password, input_type: :password_field,
opts: { autofocus: 'true', autocomplete: 'new-password', data: { controller: 'turbo-input', turbo_input_url_value: show_password_complexity_path }, aria: {describedby: 'password_hint'}})
opts: { autofocus: 'true',
autocomplete: 'new-password',
data: { controller: 'turbo-input',
turbo_input_url_value: show_password_complexity_path,
turbo_input_method_value: 'post' },
aria: {describedby: 'password_hint'}})
#password_complexity
= render PasswordComplexityComponent.new

View file

@ -5,10 +5,12 @@ import { ApplicationController } from './application_controller';
export class TurboInputController extends ApplicationController {
static values = {
url: String,
method: { type: String, default: 'get' },
loadOnConnect: { type: Boolean, default: false }
};
declare readonly urlValue: string;
declare readonly methodValue: string;
declare readonly loadOnConnectValue: boolean;
connect(): void {
@ -22,6 +24,8 @@ export class TurboInputController extends ApplicationController {
const target = this.element as HTMLInputElement;
const url = new URL(this.urlValue, document.baseURI);
url.searchParams.append(target.name, target.value);
httpRequest(url.toString()).turbo();
httpRequest(url.toString(), {
method: this.methodValue
}).turbo();
}
}

View file

@ -18,7 +18,12 @@
.fr-fieldset__element
= render Dsfr::InputComponent.new(form: f, attribute: :password, input_type: :password_field,
opts: { autofocus: 'true', autocomplete: 'new-password', data: { controller: 'turbo-input', turbo_input_url_value: show_password_complexity_path }, aria: {describedby: 'password_hint'}})
opts: { autofocus: 'true',
autocomplete: 'new-password',
data: { controller: 'turbo-input',
turbo_input_url_value: show_password_complexity_path,
turbo_input_method_value: 'post' },
aria: {describedby: 'password_hint'}})
#password_complexity
= render PasswordComplexityComponent.new

View file

@ -21,7 +21,12 @@
.fr-fieldset__element
= render Dsfr::InputComponent.new(form: f, attribute: :password, input_type: :password_field,
opts: { autofocus: 'true', autocomplete: 'new-password', data: { controller: 'turbo-input', turbo_input_url_value: show_password_complexity_path }, aria: {describedby: 'password_hint'}})
opts: { autofocus: 'true',
autocomplete: 'new-password',
data: { controller: 'turbo-input',
turbo_input_url_value: show_password_complexity_path,
turbo_input_method_value: 'post' },
aria: {describedby: 'password_hint'}})
#password_complexity
= render PasswordComplexityComponent.new

View file

@ -14,7 +14,13 @@
.fr-fieldset__element
= render Dsfr::InputComponent.new(form: f, attribute: :password, input_type: :password_field,
opts: { autofocus: 'true', autocomplete: 'new-password', data: { controller: 'turbo-input', turbo_input_url_value: show_password_complexity_path }, aria: {describedby: 'password_hint'}})
opts: { autofocus: 'true',
autocomplete: 'new-password',
data: { controller: 'turbo-input',
turbo_input_url_value: show_password_complexity_path,
turbo_input_method_value: 'post',
},
aria: {describedby: 'password_hint'}})
#password_complexity
= render PasswordComplexityComponent.new

View file

@ -18,7 +18,12 @@
.fr-fieldset__element
= render Dsfr::InputComponent.new(form: f, attribute: :password, input_type: :password_field,
opts: { autofocus: 'true', autocomplete: 'new-password', data: { controller: 'turbo-input', turbo_input_url_value: show_password_complexity_path }, aria: {describedby: 'password_hint'}})
opts: { autofocus: 'true',
autocomplete: 'new-password',
data: { controller: 'turbo-input',
turbo_input_url_value: show_password_complexity_path,
turbo_input_method_value: 'post' },
aria: {describedby: 'password_hint'}})
#password_complexity
= render PasswordComplexityComponent.new

View file

@ -20,7 +20,13 @@
.fr-fieldset__element
= render Dsfr::InputComponent.new(form: f, attribute: :password, input_type: :password_field,
opts: { autofocus: 'true', autocomplete: 'new-password', data: { controller: 'turbo-input', turbo_input_url_value: show_password_complexity_path, email_input_target: 'next'}, aria: {describedby: 'password_hint'}})
opts: { autofocus: 'true',
autocomplete: 'new-password',
data: { controller: 'turbo-input',
turbo_input_url_value: show_password_complexity_path,
turbo_input_method_value: 'post',
email_input_target: 'next' },
aria: {describedby: 'password_hint'}})
#password_complexity
= render PasswordComplexityComponent.new

View file

@ -171,7 +171,7 @@ Rails.application.routes.draw do
get 'logout' => 'users/sessions#logout'
end
get 'password_complexity' => 'password_complexity#show', as: 'show_password_complexity'
post 'password_complexity' => 'password_complexity#show', as: 'show_password_complexity'
get 'check_email' => 'email_checker#show', as: 'show_email_suggestions'
resources :targeted_user_links, only: [:show]

View file

@ -6,7 +6,7 @@ describe PasswordComplexityController, type: :controller do
{ user: { password: 'motDePasseTropFacile' } }
end
subject { get :show, format: :turbo_stream, params: params }
subject { post :show, format: :turbo_stream, params: params }
it 'computes a password score' do
subject