web/flows: attempt to fix bitwareden android compatibility (cherry-pick #7455) (#7457)

web/flows: attempt to fix bitwareden android compatibility (#7455)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Co-authored-by: Jens L <jens@goauthentik.io>
This commit is contained in:
gcp-cherry-pick-bot[bot] 2023-11-06 23:58:44 +01:00 committed by GitHub
parent 3716298639
commit 1def9865cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 25 deletions

View File

@ -80,11 +80,12 @@ export class IdentificationStage extends BaseStage<
} }
createHelperForm(): void { createHelperForm(): void {
const compatMode = "ShadyDOM" in window;
this.form = document.createElement("form"); this.form = document.createElement("form");
document.documentElement.appendChild(this.form); document.documentElement.appendChild(this.form);
// Only add the additional username input if we're in a shadow dom // Only add the additional username input if we're in a shadow dom
// otherwise it just confuses browsers // otherwise it just confuses browsers
if (!("ShadyDOM" in window)) { if (!compatMode) {
// This is a workaround for the fact that we're in a shadow dom // This is a workaround for the fact that we're in a shadow dom
// adapted from https://github.com/home-assistant/frontend/issues/3133 // adapted from https://github.com/home-assistant/frontend/issues/3133
const username = document.createElement("input"); const username = document.createElement("input");
@ -104,6 +105,8 @@ export class IdentificationStage extends BaseStage<
}; };
this.form.appendChild(username); this.form.appendChild(username);
} }
// Only add the password field when we don't already show a password field
if (!compatMode && !this.challenge.passwordFields) {
const password = document.createElement("input"); const password = document.createElement("input");
password.setAttribute("type", "password"); password.setAttribute("type", "password");
password.setAttribute("name", "password"); password.setAttribute("name", "password");
@ -128,6 +131,7 @@ export class IdentificationStage extends BaseStage<
}); });
}; };
this.form.appendChild(password); this.form.appendChild(password);
}
const totp = document.createElement("input"); const totp = document.createElement("input");
totp.setAttribute("type", "text"); totp.setAttribute("type", "text");
totp.setAttribute("name", "code"); totp.setAttribute("name", "code");