fixes
This commit is contained in:
+27
-25
@@ -20,6 +20,26 @@ const clearAuthSession = sessionStore.clearAuthSession || (() => {
|
||||
sessionStorage.removeItem("rustpad:nickname");
|
||||
});
|
||||
|
||||
function configureCredentialFields({ emailLabel, email, password, loginMode, externalAuth }) {
|
||||
const directoryLogin = loginMode && externalAuth;
|
||||
emailLabel.textContent = directoryLogin ? "E-mail / LDAP or AD Username" : "E-mail";
|
||||
email.type = directoryLogin ? "text" : "email";
|
||||
email.placeholder = directoryLogin ? "you@example.com or username" : "you@example.com";
|
||||
email.autocomplete = loginMode ? "username" : "off";
|
||||
password.autocomplete = loginMode ? "current-password" : "off";
|
||||
|
||||
if (directoryLogin) password.removeAttribute("minlength");
|
||||
else password.minLength = 8;
|
||||
|
||||
if (loginMode) {
|
||||
email.removeAttribute("data-bwignore");
|
||||
password.removeAttribute("data-bwignore");
|
||||
} else {
|
||||
email.dataset.bwignore = "true";
|
||||
password.dataset.bwignore = "true";
|
||||
}
|
||||
}
|
||||
|
||||
export function bindIdentityDialog({ dialog, onIdentity, initialMode = "login" }) {
|
||||
if (dialog.querySelector("#auth-panel")) return bindLegacyIdentityDialog({ dialog, onIdentity });
|
||||
const form = dialog.querySelector("#identity-form");
|
||||
@@ -28,6 +48,7 @@ export function bindIdentityDialog({ dialog, onIdentity, initialMode = "login" }
|
||||
const title = dialog.querySelector("#identity-title");
|
||||
const copy = dialog.querySelector("#identity-copy");
|
||||
const emailField = dialog.querySelector("#auth-email-field");
|
||||
const emailLabel = dialog.querySelector("#auth-email-label");
|
||||
const email = dialog.querySelector("#auth-email");
|
||||
const password = dialog.querySelector("#auth-password");
|
||||
const submit = dialog.querySelector("#auth-submit");
|
||||
@@ -48,7 +69,9 @@ export function bindIdentityDialog({ dialog, onIdentity, initialMode = "login" }
|
||||
? "Enter the e-mail address assigned to your local account."
|
||||
: registering
|
||||
? "Register your account with an e-mail address and password."
|
||||
: "Use your e-mail address or organization login and password.";
|
||||
: externalAuth
|
||||
? "Use your e-mail address or LDAP/AD username and password."
|
||||
: "Use your e-mail address and password.";
|
||||
|
||||
nickname.closest("label").hidden = !registering;
|
||||
nickname.disabled = !registering;
|
||||
@@ -62,21 +85,10 @@ export function bindIdentityDialog({ dialog, onIdentity, initialMode = "login" }
|
||||
resetButton.hidden = resetting || registering || externalAuth;
|
||||
backButton.hidden = !resetting;
|
||||
const loginMode = mode === "login";
|
||||
email.type = externalAuth && loginMode ? "text" : "email";
|
||||
if (externalAuth && loginMode) password.removeAttribute("minlength");
|
||||
else password.minLength = 8;
|
||||
configureCredentialFields({ emailLabel, email, password, loginMode, externalAuth });
|
||||
form.autocomplete = loginMode ? "on" : "off";
|
||||
nickname.autocomplete = "off";
|
||||
nickname.dataset.bwignore = "true";
|
||||
email.autocomplete = loginMode ? "username" : "off";
|
||||
password.autocomplete = loginMode ? "current-password" : "off";
|
||||
if (loginMode) {
|
||||
email.removeAttribute("data-bwignore");
|
||||
password.removeAttribute("data-bwignore");
|
||||
} else {
|
||||
email.dataset.bwignore = "true";
|
||||
password.dataset.bwignore = "true";
|
||||
}
|
||||
message.textContent = "";
|
||||
|
||||
queueMicrotask(() => {
|
||||
@@ -168,6 +180,7 @@ function bindLegacyIdentityDialog({ dialog, onIdentity }) {
|
||||
const message = dialog.querySelector("#identity-error");
|
||||
const modeTitle = dialog.querySelector("#auth-mode-title");
|
||||
const emailField = dialog.querySelector("#auth-email-field");
|
||||
const emailLabel = dialog.querySelector("#auth-email-label");
|
||||
const email = dialog.querySelector("#auth-email");
|
||||
const password = dialog.querySelector("#auth-password");
|
||||
const authSubmit = dialog.querySelector("#auth-submit");
|
||||
@@ -205,21 +218,10 @@ function bindLegacyIdentityDialog({ dialog, onIdentity }) {
|
||||
modeTitle.textContent = mode === "register" ? "Register" : "Log in";
|
||||
authSubmit.textContent = mode === "register" ? "Register and continue" : "Log in and continue";
|
||||
const loginMode = mode === "login";
|
||||
email.type = externalAuth && loginMode ? "text" : "email";
|
||||
if (externalAuth && loginMode) password.removeAttribute("minlength");
|
||||
else password.minLength = 8;
|
||||
configureCredentialFields({ emailLabel, email, password, loginMode, externalAuth });
|
||||
form.autocomplete = loginMode ? "on" : "off";
|
||||
nickname.autocomplete = "off";
|
||||
nickname.dataset.bwignore = "true";
|
||||
email.autocomplete = loginMode ? "username" : "off";
|
||||
password.autocomplete = loginMode ? "current-password" : "off";
|
||||
if (loginMode) {
|
||||
email.removeAttribute("data-bwignore");
|
||||
password.removeAttribute("data-bwignore");
|
||||
} else {
|
||||
email.dataset.bwignore = "true";
|
||||
password.dataset.bwignore = "true";
|
||||
}
|
||||
message.textContent = "";
|
||||
queueMicrotask(() => (mode === "register" ? nickname : email).focus());
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user