From 4338a6b26af2a7e3608c17e4529ed9d1c6385cef Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Thu, 26 Aug 2021 01:54:53 +0200
Subject: [PATCH] [BUGFIX] Fix initialization of TOTP info modal

The TOTP info modal displays the OTP auth url
along with a description. This content however
is added to the modal body by a callback. To
prevent the "modal content empty" warning
from being shown, the modal is now initialized
with an empty string as content.

Resolves: #94999
Releases: master
Change-Id: I0a8c274466d4f62da8edb26a4c2b547b66be3ba6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70761
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
---
 .../Public/TypeScript/Authentication/MfaProvider/Totp.ts      | 1 +
 .../Public/JavaScript/Authentication/MfaProvider/Totp.js      | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Build/Sources/TypeScript/core/Resources/Public/TypeScript/Authentication/MfaProvider/Totp.ts b/Build/Sources/TypeScript/core/Resources/Public/TypeScript/Authentication/MfaProvider/Totp.ts
index a2e0a1e2afe3..b5da5e84a15c 100644
--- a/Build/Sources/TypeScript/core/Resources/Public/TypeScript/Authentication/MfaProvider/Totp.ts
+++ b/Build/Sources/TypeScript/core/Resources/Public/TypeScript/Authentication/MfaProvider/Totp.ts
@@ -41,6 +41,7 @@ class MfaTotpUrlButton extends LitElement {
   private showTotpAuthUrlModal(): void {
     Modal.advanced({
       title: this.title,
+      content: '', // Empty content, will be filled by the callback
       buttons: [
         {
           trigger: (): void => Modal.dismiss(),
diff --git a/typo3/sysext/core/Resources/Public/JavaScript/Authentication/MfaProvider/Totp.js b/typo3/sysext/core/Resources/Public/JavaScript/Authentication/MfaProvider/Totp.js
index ff26405a275d..a33644621026 100644
--- a/typo3/sysext/core/Resources/Public/JavaScript/Authentication/MfaProvider/Totp.js
+++ b/typo3/sysext/core/Resources/Public/JavaScript/Authentication/MfaProvider/Totp.js
@@ -10,7 +10,7 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-var __decorate=this&&this.__decorate||function(t,e,o,r){var i,l=arguments.length,n=l<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,o,r);else for(var d=t.length-1;d>=0;d--)(i=t[d])&&(n=(l<3?i(n):l>3?i(e,o,n):i(e,o))||n);return l>3&&n&&Object.defineProperty(e,o,n),n};define(["require","exports","lit","lit/decorators","TYPO3/CMS/Backend/Modal"],(function(t,e,o,r,i){"use strict";var l;Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.modalBody=".t3js-modal-body"}(l||(l={}));let n=class extends o.LitElement{constructor(){super(),this.addEventListener("click",t=>{t.preventDefault(),this.showTotpAuthUrlModal()})}render(){return o.html`<slot></slot>`}showTotpAuthUrlModal(){i.advanced({title:this.title,buttons:[{trigger:()=>i.dismiss(),text:this.ok||"OK",active:!0,btnClass:"btn-default",name:"ok"}],callback:t=>{o.render(o.html`
+var __decorate=this&&this.__decorate||function(t,e,o,r){var i,n=arguments.length,l=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,o,r);else for(var d=t.length-1;d>=0;d--)(i=t[d])&&(l=(n<3?i(l):n>3?i(e,o,l):i(e,o))||l);return n>3&&l&&Object.defineProperty(e,o,l),l};define(["require","exports","lit","lit/decorators","TYPO3/CMS/Backend/Modal"],(function(t,e,o,r,i){"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.modalBody=".t3js-modal-body"}(n||(n={}));let l=class extends o.LitElement{constructor(){super(),this.addEventListener("click",t=>{t.preventDefault(),this.showTotpAuthUrlModal()})}render(){return o.html`<slot></slot>`}showTotpAuthUrlModal(){i.advanced({title:this.title,content:"",buttons:[{trigger:()=>i.dismiss(),text:this.ok||"OK",active:!0,btnClass:"btn-default",name:"ok"}],callback:t=>{o.render(o.html`
             <p>${this.description}</p>
             <pre>${this.url}</pre>
-          `,t[0].querySelector(l.modalBody))}})}};__decorate([r.property({type:String})],n.prototype,"url",void 0),__decorate([r.property({type:String})],n.prototype,"title",void 0),__decorate([r.property({type:String})],n.prototype,"description",void 0),__decorate([r.property({type:String})],n.prototype,"ok",void 0),n=__decorate([r.customElement("typo3-mfa-totp-url-info-button")],n)}));
\ No newline at end of file
+          `,t[0].querySelector(n.modalBody))}})}};__decorate([r.property({type:String})],l.prototype,"url",void 0),__decorate([r.property({type:String})],l.prototype,"title",void 0),__decorate([r.property({type:String})],l.prototype,"description",void 0),__decorate([r.property({type:String})],l.prototype,"ok",void 0),l=__decorate([r.customElement("typo3-mfa-totp-url-info-button")],l)}));
\ No newline at end of file
-- 
GitLab