fix: address PR review feedback on password suggestions
Remove redundant tests, rename requirement translations to suggestion for clearer i18n, simplify password input state and requirement display.
This commit is contained in:
41 files changed
+50
-94
No files matched your search
@@ -42,37 +42,6 @@ describe("Onboarding", () => {
|
|||||||
await homarrContainer.stop();
|
await homarrContainer.stop();
|
||||||
}, 60_000);
|
}, 60_000);
|
||||||
|
|
||||||
test("Credentials onboarding with special character password should be successful", async () => {
|
|
||||||
const { db, localMountPath } = await createSqliteDbFileAsync();
|
|
||||||
const homarrContainer = await createHomarrContainer({
|
|
||||||
mounts: {
|
|
||||||
"/appdata": localMountPath,
|
|
||||||
},
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
const browser = await chromium.launch();
|
|
||||||
const context = await browser.newContext();
|
|
||||||
const page = await context.newPage();
|
|
||||||
const actions = new OnboardingActions(page, db);
|
|
||||||
const assertions = new OnboardingAssertions(page, db);
|
|
||||||
|
|
||||||
await page.goto(`http://${homarrContainer.getHost()}:${homarrContainer.getMappedPort(7575)}`);
|
|
||||||
await actions.startOnboardingAsync("scratch");
|
|
||||||
await actions.processUserStepAsync({
|
|
||||||
username: "admin",
|
|
||||||
password: "LoveHomarr<3",
|
|
||||||
confirmPassword: "LoveHomarr<3",
|
|
||||||
});
|
|
||||||
await actions.processSettingsStepAsync();
|
|
||||||
|
|
||||||
await assertions.assertFinishStepVisibleAsync();
|
|
||||||
await assertions.assertUserAndAdminGroupInsertedAsync("admin");
|
|
||||||
await assertions.assertDbOnboardingStepAsync("finish");
|
|
||||||
|
|
||||||
await browser.close();
|
|
||||||
await homarrContainer.stop();
|
|
||||||
}, 60_000);
|
|
||||||
|
|
||||||
test("External provider onboarding setup should be successful", async () => {
|
test("External provider onboarding setup should be successful", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { db, localMountPath } = await createSqliteDbFileAsync();
|
const { db, localMountPath } = await createSqliteDbFileAsync();
|
||||||
|
|||||||
@@ -53,12 +53,4 @@ describe("comparePasswordsAsync should compare passwords correctly", () => {
|
|||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(false);
|
expect(result).toBe(false);
|
||||||
});
|
});
|
||||||
it("should return true for passwords with special characters like LoveHomarr<3", async () => {
|
|
||||||
const password = "LoveHomarr<3";
|
|
||||||
const hash = await hashPasswordAsync(password);
|
|
||||||
|
|
||||||
const result = await comparePasswordsAsync(password, hash);
|
|
||||||
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Contrasenya",
|
"label": "Contrasenya",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Inclou com a mínim 8 caràcters",
|
"length": "Inclou com a mínim 8 caràcters",
|
||||||
"lowercase": "Inclou minúscules",
|
"lowercase": "Inclou minúscules",
|
||||||
"uppercase": "Inclou majúscules",
|
"uppercase": "Inclou majúscules",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "密码",
|
"label": "密码",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "至少包含 8 个字符",
|
"length": "至少包含 8 个字符",
|
||||||
"lowercase": "包含小写字母",
|
"lowercase": "包含小写字母",
|
||||||
"uppercase": "包含大写字母",
|
"uppercase": "包含大写字母",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "crwdns26:0crwdne26:0",
|
"label": "crwdns26:0crwdne26:0",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "crwdns28:0crwdne28:0",
|
"length": "crwdns28:0crwdne28:0",
|
||||||
"lowercase": "crwdns30:0crwdne30:0",
|
"lowercase": "crwdns30:0crwdne30:0",
|
||||||
"uppercase": "crwdns32:0crwdne32:0",
|
"uppercase": "crwdns32:0crwdne32:0",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Heslo",
|
"label": "Heslo",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Obsahuje alespoň 8 znaků",
|
"length": "Obsahuje alespoň 8 znaků",
|
||||||
"lowercase": "Obsahuje malé písmeno",
|
"lowercase": "Obsahuje malé písmeno",
|
||||||
"uppercase": "Obsahuje velké písmeno",
|
"uppercase": "Obsahuje velké písmeno",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Adgangskode",
|
"label": "Adgangskode",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Inkluderer mindst 8 tegn",
|
"length": "Inkluderer mindst 8 tegn",
|
||||||
"lowercase": "Inkluderer små bogstaver",
|
"lowercase": "Inkluderer små bogstaver",
|
||||||
"uppercase": "Inkluderer store bogstaver",
|
"uppercase": "Inkluderer store bogstaver",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Passwort",
|
"label": "Passwort",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Enthält mindestens 8 Zeichen",
|
"length": "Enthält mindestens 8 Zeichen",
|
||||||
"lowercase": "Enthält Kleinbuchstaben",
|
"lowercase": "Enthält Kleinbuchstaben",
|
||||||
"uppercase": "Enthält Großbuchstaben",
|
"uppercase": "Enthält Großbuchstaben",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Passwort",
|
"label": "Passwort",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Enthält mindestens 8 Zeichen",
|
"length": "Enthält mindestens 8 Zeichen",
|
||||||
"lowercase": "Enthält Kleinbuchstaben",
|
"lowercase": "Enthält Kleinbuchstaben",
|
||||||
"uppercase": "Enthält Großbuchstaben",
|
"uppercase": "Enthält Großbuchstaben",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Κωδικός",
|
"label": "Κωδικός",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "Περιλαμβάνει πεζό γράμμα",
|
"lowercase": "Περιλαμβάνει πεζό γράμμα",
|
||||||
"uppercase": "Περιλαμβάνει κεφαλαίο γράμμα",
|
"uppercase": "Περιλαμβάνει κεφαλαίο γράμμα",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Password",
|
"label": "Password",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Includes a minimum of 8 characters",
|
"length": "Includes a minimum of 8 characters",
|
||||||
"lowercase": "Includes a lower-case letter",
|
"lowercase": "Includes a lower-case letter",
|
||||||
"uppercase": "Includes an upper-case letter",
|
"uppercase": "Includes an upper-case letter",
|
||||||
|
|||||||
@@ -133,12 +133,12 @@
|
|||||||
"password": {
|
"password": {
|
||||||
"label": "Password",
|
"label": "Password",
|
||||||
"suggestionsTitle": "Password suggestions",
|
"suggestionsTitle": "Password suggestions",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "At least 8 characters",
|
"length": "At least 8 characters",
|
||||||
"lowercase": "Suggested: includes lowercase letter",
|
"lowercase": "Includes lowercase letter",
|
||||||
"uppercase": "Suggested: includes uppercase letter",
|
"uppercase": "Includes uppercase letter",
|
||||||
"number": "Suggested: includes number",
|
"number": "Includes number",
|
||||||
"special": "Suggested: includes special symbol"
|
"special": "Includes special symbol"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"passwordConfirm": {
|
"passwordConfirm": {
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Contraseña",
|
"label": "Contraseña",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Incluye al menos 8 caracteres",
|
"length": "Incluye al menos 8 caracteres",
|
||||||
"lowercase": "Incluye al menos una letra minúscula",
|
"lowercase": "Incluye al menos una letra minúscula",
|
||||||
"uppercase": "Incluye al menos una letra mayúscula",
|
"uppercase": "Incluye al menos una letra mayúscula",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "",
|
"label": "",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "",
|
"lowercase": "",
|
||||||
"uppercase": "",
|
"uppercase": "",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Mot de passe",
|
"label": "Mot de passe",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Contient au moins 8 caractères",
|
"length": "Contient au moins 8 caractères",
|
||||||
"lowercase": "Inclut une lettre minuscule",
|
"lowercase": "Inclut une lettre minuscule",
|
||||||
"uppercase": "Inclut une lettre majuscule",
|
"uppercase": "Inclut une lettre majuscule",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "סיסמה",
|
"label": "סיסמה",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "כולל לפחות 8 תווים",
|
"length": "כולל לפחות 8 תווים",
|
||||||
"lowercase": "אפשר אותיות קטנות",
|
"lowercase": "אפשר אותיות קטנות",
|
||||||
"uppercase": "אפשר אותיות גדולות",
|
"uppercase": "אפשר אותיות גדולות",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Lozinka",
|
"label": "Lozinka",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "Uključuje mala slova",
|
"lowercase": "Uključuje mala slova",
|
||||||
"uppercase": "Uključuje veliko slovo",
|
"uppercase": "Uključuje veliko slovo",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Jelszó",
|
"label": "Jelszó",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Tartalmazzon legalább 8 karaktert",
|
"length": "Tartalmazzon legalább 8 karaktert",
|
||||||
"lowercase": "Tartalmazzon kisbetűt",
|
"lowercase": "Tartalmazzon kisbetűt",
|
||||||
"uppercase": "Tartalmazzon nagybetűt",
|
"uppercase": "Tartalmazzon nagybetűt",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Password",
|
"label": "Password",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Include almeno 8 caratteri",
|
"length": "Include almeno 8 caratteri",
|
||||||
"lowercase": "Include lettera minuscola",
|
"lowercase": "Include lettera minuscola",
|
||||||
"uppercase": "Include lettera maiuscola",
|
"uppercase": "Include lettera maiuscola",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "パスワード",
|
"label": "パスワード",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "少なくとも 8 文字以上を含む",
|
"length": "少なくとも 8 文字以上を含む",
|
||||||
"lowercase": "小文字を含む",
|
"lowercase": "小文字を含む",
|
||||||
"uppercase": "大文字を含む",
|
"uppercase": "大文字を含む",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "비밀번호",
|
"label": "비밀번호",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "소문자 포함",
|
"lowercase": "소문자 포함",
|
||||||
"uppercase": "대문자 포함",
|
"uppercase": "대문자 포함",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Slaptažodis",
|
"label": "Slaptažodis",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "",
|
"lowercase": "",
|
||||||
"uppercase": "",
|
"uppercase": "",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Parole",
|
"label": "Parole",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "Ietver mazo burtu",
|
"lowercase": "Ietver mazo burtu",
|
||||||
"uppercase": "Ietver lielo burtu",
|
"uppercase": "Ietver lielo burtu",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Wachtwoord",
|
"label": "Wachtwoord",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Bevat ten minste 8 tekens",
|
"length": "Bevat ten minste 8 tekens",
|
||||||
"lowercase": "Inclusief kleine letter",
|
"lowercase": "Inclusief kleine letter",
|
||||||
"uppercase": "Inclusief hoofdletter",
|
"uppercase": "Inclusief hoofdletter",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Passord",
|
"label": "Passord",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Inkluderer minst 8 tegn",
|
"length": "Inkluderer minst 8 tegn",
|
||||||
"lowercase": "Inkluderer liten bokstav",
|
"lowercase": "Inkluderer liten bokstav",
|
||||||
"uppercase": "Inkluderer stor bokstav",
|
"uppercase": "Inkluderer stor bokstav",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Hasło",
|
"label": "Hasło",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Zawiera co najmniej 8 znaków",
|
"length": "Zawiera co najmniej 8 znaków",
|
||||||
"lowercase": "Zawiera małą literę",
|
"lowercase": "Zawiera małą literę",
|
||||||
"uppercase": "Zawiera wielką literę",
|
"uppercase": "Zawiera wielką literę",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Senha",
|
"label": "Senha",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Inclua pelo menos 8 caracteres",
|
"length": "Inclua pelo menos 8 caracteres",
|
||||||
"lowercase": "Inclui letras minúsculas",
|
"lowercase": "Inclui letras minúsculas",
|
||||||
"uppercase": "Inclui letras maiúsculas",
|
"uppercase": "Inclui letras maiúsculas",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "",
|
"label": "",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "",
|
"lowercase": "",
|
||||||
"uppercase": "",
|
"uppercase": "",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Parola",
|
"label": "Parola",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "Să includă litere mici",
|
"lowercase": "Să includă litere mici",
|
||||||
"uppercase": "Să includă litere mari",
|
"uppercase": "Să includă litere mari",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Пароль",
|
"label": "Пароль",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Содержит не менее 8 символов",
|
"length": "Содержит не менее 8 символов",
|
||||||
"lowercase": "Содержит строчную букву",
|
"lowercase": "Содержит строчную букву",
|
||||||
"uppercase": "Содержит заглавную букву",
|
"uppercase": "Содержит заглавную букву",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Heslo",
|
"label": "Heslo",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Obsahuje aspoň 8 znakov",
|
"length": "Obsahuje aspoň 8 znakov",
|
||||||
"lowercase": "Zahŕňa malé písmeno",
|
"lowercase": "Zahŕňa malé písmeno",
|
||||||
"uppercase": "Zahŕňa veľké písmená",
|
"uppercase": "Zahŕňa veľké písmená",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Geslo",
|
"label": "Geslo",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "",
|
"length": "",
|
||||||
"lowercase": "Vključuje male črke",
|
"lowercase": "Vključuje male črke",
|
||||||
"uppercase": "Vključuje velike tiskane črke",
|
"uppercase": "Vključuje velike tiskane črke",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Lösenord",
|
"label": "Lösenord",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Använd minst 8 tecken",
|
"length": "Använd minst 8 tecken",
|
||||||
"lowercase": "Använd liten bokstav",
|
"lowercase": "Använd liten bokstav",
|
||||||
"uppercase": "Använd stor bokstav",
|
"uppercase": "Använd stor bokstav",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Şifre",
|
"label": "Şifre",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "En az 8 karakter içermeli",
|
"length": "En az 8 karakter içermeli",
|
||||||
"lowercase": "Küçük harf içermeli",
|
"lowercase": "Küçük harf içermeli",
|
||||||
"uppercase": "Büyük harf içermeli",
|
"uppercase": "Büyük harf içermeli",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Пароль",
|
"label": "Пароль",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Включає принаймні 8 символів",
|
"length": "Включає принаймні 8 символів",
|
||||||
"lowercase": "Включає малу літеру",
|
"lowercase": "Включає малу літеру",
|
||||||
"uppercase": "Включає велику літеру",
|
"uppercase": "Включає велику літеру",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "Mật khẩu",
|
"label": "Mật khẩu",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "Bao gồm ít nhất 8 kí tự",
|
"length": "Bao gồm ít nhất 8 kí tự",
|
||||||
"lowercase": "Bao gồm chữ thường",
|
"lowercase": "Bao gồm chữ thường",
|
||||||
"uppercase": "Bao gồm chữ in hoa",
|
"uppercase": "Bao gồm chữ in hoa",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"label": "密碼",
|
"label": "密碼",
|
||||||
"requirement": {
|
"suggestion": {
|
||||||
"length": "至少包含 8 個字符",
|
"length": "至少包含 8 個字符",
|
||||||
"lowercase": "包含小寫字母",
|
"lowercase": "包含小寫字母",
|
||||||
"uppercase": "包含大寫字母",
|
"uppercase": "包含大寫字母",
|
||||||
|
|||||||
@@ -20,16 +20,15 @@ export const CustomPasswordInput = ({ withPasswordRequirements, ...props }: Cust
|
|||||||
};
|
};
|
||||||
|
|
||||||
const WithPasswordRequirements = (props: PasswordInputProps) => {
|
const WithPasswordRequirements = (props: PasswordInputProps) => {
|
||||||
const [internalValue, setInternalValue] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const password = props.value ?? internalValue;
|
|
||||||
|
|
||||||
const onChange = (event: ChangeEvent<HTMLInputElement>) => {
|
const onChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
setInternalValue(event.currentTarget.value);
|
setPassword(event.currentTarget.value);
|
||||||
props.onChange?.(event);
|
props.onChange?.(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PasswordRequirementsPopover password={String(password)}>
|
<PasswordRequirementsPopover password={password}>
|
||||||
<PasswordInput {...props} onChange={onChange} />
|
<PasswordInput {...props} onChange={onChange} />
|
||||||
</PasswordRequirementsPopover>
|
</PasswordRequirementsPopover>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import { rem, Text } from "@mantine/core";
|
import { rem, Text } from "@mantine/core";
|
||||||
import { IconCheck, IconPoint } from "@tabler/icons-react";
|
import { IconCheck, IconPoint } from "@tabler/icons-react";
|
||||||
|
|
||||||
const requirementDisplay = {
|
const getRequirementDisplay = (meets: boolean) =>
|
||||||
met: { color: "teal", Icon: IconCheck },
|
({
|
||||||
unmet: { color: "dimmed", Icon: IconPoint },
|
true: { color: "teal", Icon: IconCheck },
|
||||||
} as const;
|
false: { color: "dimmed", Icon: IconPoint },
|
||||||
|
})[String(meets) as "true" | "false"];
|
||||||
const displayKey = {
|
|
||||||
true: "met",
|
|
||||||
false: "unmet",
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export function PasswordRequirement({ meets, label }: { meets: boolean; label: string }) {
|
export function PasswordRequirement({ meets, label }: { meets: boolean; label: string }) {
|
||||||
const display = requirementDisplay[displayKey[String(meets) as "true" | "false"]];
|
const display = getRequirementDisplay(meets);
|
||||||
const Icon = display.Icon;
|
const Icon = display.Icon;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const PasswordRequirementsPopover = ({ password, children }: PropsWithChi
|
|||||||
};
|
};
|
||||||
|
|
||||||
const useRequirements = () => {
|
const useRequirements = () => {
|
||||||
const t = useScopedI18n("user.field.password.requirement");
|
const t = useScopedI18n("user.field.password.suggestion");
|
||||||
|
|
||||||
return passwordRequirements.map(({ check, value }) => ({ check, label: t(value) }));
|
return passwordRequirements.map(({ check, value }) => ({ check, label: t(value) }));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const passwordRequirements = [
|
|||||||
{ check: regexCheck(/[$&+,:;=?@#|'<>.^*()%!\-~`"_/\\[\]{}]/), value: "special" },
|
{ check: regexCheck(/[$&+,:;=?@#|'<>.^*()%!\-~`"_/\\[\]{}]/), value: "special" },
|
||||||
] satisfies {
|
] satisfies {
|
||||||
check: (value: string) => boolean;
|
check: (value: string) => boolean;
|
||||||
value: keyof TranslationObject["user"]["field"]["password"]["requirement"];
|
value: keyof TranslationObject["user"]["field"]["password"]["suggestion"];
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
export const userPasswordSchema = z.string().min(8).max(255);
|
export const userPasswordSchema = z.string().min(8).max(255);
|
||||||
|
|||||||
Reference in new issue
Block a user