Skip to content

Commit

Permalink
[BUGFIX] Consider empty or invalid password policy reference
Browse files Browse the repository at this point in the history
In case `$GLOBALS['TYPO3_CONF_VARS']['BE']['passwordPolicy']`
is disabled or set to a preset that actually does not exist,
the backend editing view should not issue JavaScript errors
on the missing `#password-policy-info` element.

Resolves: #102668
Releases: main, 12.4
Change-Id: Iafb418254f73f379364b04c5d45d33111bef7d13
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82123
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
ohader authored and o-ba committed Dec 14, 2023
1 parent e4105ac commit 9a41fb0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Expand Up @@ -28,7 +28,7 @@ import { selector } from '@typo3/core/literals';
*/
class PasswordElement extends HTMLElement {
private element: HTMLInputElement = null;
private passwordPolicyInfo: HTMLElement = null;
private passwordPolicyInfo: HTMLElement|null = null;
private passwordPolicySet: boolean = false;

public connectedCallback(): void {
Expand All @@ -49,7 +49,7 @@ class PasswordElement extends HTMLElement {
}

private registerEventHandler(): void {
if (this.passwordPolicySet) {
if (this.passwordPolicySet && this.passwordPolicyInfo !== null) {
this.element.addEventListener('focusin', (): void => {
this.passwordPolicyInfo.classList.remove('hidden');
});
Expand Down
Expand Up @@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
import{selector}from"@typo3/core/literals.js";class PasswordElement extends HTMLElement{constructor(){super(...arguments),this.element=null,this.passwordPolicyInfo=null,this.passwordPolicySet=!1}connectedCallback(){const e=this.getAttribute("recordFieldId");null!==e&&(this.element=this.querySelector(selector`#${e}`),this.element&&(this.passwordPolicyInfo=this.querySelector(selector`#password-policy-info-${this.element.id}`),this.passwordPolicySet=""!==(this.getAttribute("passwordPolicy")||""),this.registerEventHandler()))}registerEventHandler(){this.passwordPolicySet&&(this.element.addEventListener("focusin",(()=>{this.passwordPolicyInfo.classList.remove("hidden")})),this.element.addEventListener("focusout",(()=>{this.passwordPolicyInfo.classList.add("hidden")})))}}window.customElements.define("typo3-formengine-element-password",PasswordElement);
import{selector}from"@typo3/core/literals.js";class PasswordElement extends HTMLElement{constructor(){super(...arguments),this.element=null,this.passwordPolicyInfo=null,this.passwordPolicySet=!1}connectedCallback(){const e=this.getAttribute("recordFieldId");null!==e&&(this.element=this.querySelector(selector`#${e}`),this.element&&(this.passwordPolicyInfo=this.querySelector(selector`#password-policy-info-${this.element.id}`),this.passwordPolicySet=""!==(this.getAttribute("passwordPolicy")||""),this.registerEventHandler()))}registerEventHandler(){this.passwordPolicySet&&null!==this.passwordPolicyInfo&&(this.element.addEventListener("focusin",(()=>{this.passwordPolicyInfo.classList.remove("hidden")})),this.element.addEventListener("focusout",(()=>{this.passwordPolicyInfo.classList.add("hidden")})))}}window.customElements.define("typo3-formengine-element-password",PasswordElement);

0 comments on commit 9a41fb0

Please sign in to comment.