Fix: allow custom email (!), require a mail confirmation
previous code was wrong, it was impossible to choose another email than the FC one
This commit is contained in:
parent
4cd6e08a3d
commit
2a25171738
2 changed files with 28 additions and 5 deletions
|
@ -1,12 +1,27 @@
|
||||||
import { ApplicationController } from './application_controller';
|
import { ApplicationController } from './application_controller';
|
||||||
|
|
||||||
export class EmailFranceConnectController extends ApplicationController {
|
export class EmailFranceConnectController extends ApplicationController {
|
||||||
static targets = ['useFranceConnectEmail', 'emailField', 'submit', 'emailInput'];
|
static targets = [
|
||||||
|
'useFranceConnectEmail',
|
||||||
|
'emailField',
|
||||||
|
'submit',
|
||||||
|
'emailInput',
|
||||||
|
'form'
|
||||||
|
];
|
||||||
|
|
||||||
emailFieldTarget!: HTMLElement;
|
emailFieldTarget!: HTMLElement;
|
||||||
useFranceConnectEmailTargets!: HTMLInputElement[];
|
useFranceConnectEmailTargets!: HTMLInputElement[];
|
||||||
submitTarget!: HTMLButtonElement;
|
submitTarget!: HTMLButtonElement;
|
||||||
emailInputTarget!: HTMLInputElement;
|
emailInputTarget!: HTMLInputElement;
|
||||||
|
formTarget!: HTMLFormElement;
|
||||||
|
|
||||||
|
fcEmailPathValue!: string;
|
||||||
|
customEmailPathValue!: string;
|
||||||
|
|
||||||
|
static values = {
|
||||||
|
fcEmailPath: String,
|
||||||
|
customEmailPath: String
|
||||||
|
};
|
||||||
|
|
||||||
triggerEmailField() {
|
triggerEmailField() {
|
||||||
if (this.useFCEmail()) {
|
if (this.useFCEmail()) {
|
||||||
|
@ -15,11 +30,15 @@ export class EmailFranceConnectController extends ApplicationController {
|
||||||
|
|
||||||
this.emailInputTarget.removeAttribute('required');
|
this.emailInputTarget.removeAttribute('required');
|
||||||
this.emailInputTarget.value = '';
|
this.emailInputTarget.value = '';
|
||||||
|
|
||||||
|
this.formTarget.action = this.fcEmailPathValue;
|
||||||
} else {
|
} else {
|
||||||
this.emailFieldTarget.classList.remove('hidden');
|
this.emailFieldTarget.classList.remove('hidden');
|
||||||
this.emailFieldTarget.setAttribute('aria-hidden', 'false');
|
this.emailFieldTarget.setAttribute('aria-hidden', 'false');
|
||||||
|
|
||||||
this.emailInputTarget.setAttribute('required', '');
|
this.emailInputTarget.setAttribute('required', '');
|
||||||
|
|
||||||
|
this.formTarget.action = this.customEmailPathValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +51,10 @@ export class EmailFranceConnectController extends ApplicationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
useFCEmail() {
|
useFCEmail() {
|
||||||
return this.useFranceConnectEmailTargets.find(
|
return (
|
||||||
(target) => target.checked
|
this.useFranceConnectEmailTargets.find((target) => target.checked)
|
||||||
)?.value === 'true' || false;
|
?.value === 'true' || false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmailInputFilled() {
|
isEmailInputFilled() {
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
%fieldset.fr-fieldset
|
%fieldset.fr-fieldset
|
||||||
= form_with url: france_connect_particulier_merge_using_fc_email_path,
|
= form_with url: france_connect_particulier_merge_using_fc_email_path,
|
||||||
method: :post,
|
method: :post,
|
||||||
data: { controller: 'email-france-connect' } do |f|
|
data: { controller: 'email-france-connect',
|
||||||
|
email_france_connect_fc_email_path_value: france_connect_particulier_merge_using_fc_email_path,
|
||||||
|
email_france_connect_custom_email_path_value: france_connect_particulier_send_email_merge_request_path,
|
||||||
|
email_france_connect_target: "form" } do |f|
|
||||||
|
|
||||||
= hidden_field_tag :merge_token, @fci.merge_token
|
= hidden_field_tag :merge_token, @fci.merge_token
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue