web/flows: attempt to fix bitwareden android compatibility (#7455)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
fe1a06ebf2
commit
a7933c84c1
|
@ -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,30 +105,33 @@ export class IdentificationStage extends BaseStage<
|
||||||
};
|
};
|
||||||
this.form.appendChild(username);
|
this.form.appendChild(username);
|
||||||
}
|
}
|
||||||
const password = document.createElement("input");
|
// Only add the password field when we don't already show a password field
|
||||||
password.setAttribute("type", "password");
|
if (!compatMode && !this.challenge.passwordFields) {
|
||||||
password.setAttribute("name", "password");
|
const password = document.createElement("input");
|
||||||
password.setAttribute("autocomplete", "current-password");
|
password.setAttribute("type", "password");
|
||||||
password.onkeyup = (ev: KeyboardEvent) => {
|
password.setAttribute("name", "password");
|
||||||
if (ev.key == "Enter") {
|
password.setAttribute("autocomplete", "current-password");
|
||||||
this.submitForm(ev);
|
password.onkeyup = (ev: KeyboardEvent) => {
|
||||||
}
|
if (ev.key == "Enter") {
|
||||||
const el = ev.target as HTMLInputElement;
|
this.submitForm(ev);
|
||||||
// Because the password field is not actually on this page,
|
}
|
||||||
// and we want to 'prefill' the password for the user,
|
const el = ev.target as HTMLInputElement;
|
||||||
// save it globally
|
// Because the password field is not actually on this page,
|
||||||
PasswordManagerPrefill.password = el.value;
|
// and we want to 'prefill' the password for the user,
|
||||||
// Because password managers fill username, then password,
|
// save it globally
|
||||||
// we need to re-focus the uid_field here too
|
PasswordManagerPrefill.password = el.value;
|
||||||
(this.shadowRoot || this)
|
// Because password managers fill username, then password,
|
||||||
.querySelectorAll<HTMLInputElement>("input[name=uidField]")
|
// we need to re-focus the uid_field here too
|
||||||
.forEach((input) => {
|
(this.shadowRoot || this)
|
||||||
// Because we assume only one input field exists that matches this
|
.querySelectorAll<HTMLInputElement>("input[name=uidField]")
|
||||||
// call focus so the user can press enter
|
.forEach((input) => {
|
||||||
input.focus();
|
// Because we assume only one input field exists that matches this
|
||||||
});
|
// call focus so the user can press enter
|
||||||
};
|
input.focus();
|
||||||
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");
|
||||||
|
|
Reference in New Issue