diff --git a/source/components/form/login.mjs b/source/components/form/login.mjs index 115f18f3897cc481e35975508d62bc3c338cb863..16f2456db00bad071ff730211a42e2d883ed89d2 100644 --- a/source/components/form/login.mjs +++ b/source/components/form/login.mjs @@ -205,6 +205,7 @@ class Login extends CustomElement { * @property {Function} actions.click Callback function for generic click actions within the login component * @property {Object} callbacks Optional callback hooks for modifying internal behavior * @property {Function} callbacks.username A function that receives and can transform the entered username before submission + * @property {Function} callbacks.forgotPassword A function that receives and can transform the entered email before submission * @property {number} digits Number of digits required for second factor or password reset code input * @property {Object[]} successUrls List of URLs shown after successful login (e.g., home or logout) * @property {string} successUrls.label Label for the success URL (displayed) @@ -274,6 +275,7 @@ class Login extends CustomElement { callbacks : { username : null, + forgotPassword : null, }, digits: 6, @@ -1310,8 +1312,17 @@ function initEventHandler() { const emailElement = this.shadowRoot.querySelector("input[name='email']"); // get username and password - const mail = emailElement.value; - const valid = emailElement.checkValidity(); + let mail = emailElement.value; + let valid = emailElement.checkValidity(); + + const mailCallback = this.getOption("callbacks.forgotPassword"); + if (isFunction(mailCallback)) { + const mailCallbackResult = mailCallback.call(this, mail); + if (mailCallbackResult !== undefined) { + mail = mailCallbackResult; + valid = true; + } + } let msg = null; if (mail === "" || mail === null) {