Module now exports functions that check if a password is strong enough and equal to a potential confirmation field
ref #106
This commit is contained in:
parent
7862f44653
commit
b2509e9e53
@ -1,18 +1,26 @@
|
|||||||
<script>
|
<script context="module">
|
||||||
import { getLocaleFromNavigator, _ } from "svelte-i18n";
|
import { passwordStrength } from "check-password-strength";
|
||||||
import { passwordStrength } from "check-password-strength";
|
export function password_strong_enough(password_change) {
|
||||||
export let password_change;
|
let strength = passwordStrength(password_change);
|
||||||
export let password_confirm;
|
return (strength?.contains.includes("lowercase") &&
|
||||||
|
|
||||||
$: strength = passwordStrength(password_change);
|
|
||||||
$: passwords_match =
|
|
||||||
!password_confirm || password_confirm === password_change;
|
|
||||||
$: update_password_enabled =
|
|
||||||
strength?.contains.includes("lowercase") &&
|
|
||||||
strength?.contains.includes("uppercase") &&
|
strength?.contains.includes("uppercase") &&
|
||||||
strength?.contains.includes("number") &&
|
strength?.contains.includes("number") &&
|
||||||
strength?.length > 9 &&
|
strength?.length > 9);
|
||||||
passwords_match == true;
|
}
|
||||||
|
export function password_strong_enough_and_equal(password_change, password_confirm){
|
||||||
|
return password_strong_enough(password_change) && password_change === password_confirm;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getLocaleFromNavigator, _ } from "svelte-i18n";
|
||||||
|
import { passwordStrength as Strength } from "check-password-strength";
|
||||||
|
export let password_change;
|
||||||
|
export let password_confirm;
|
||||||
|
|
||||||
|
$: strength = Strength(password_change);
|
||||||
|
$: passwords_match =
|
||||||
|
!password_confirm || password_confirm === password_change;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="ml-4">
|
<div class="ml-4">
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import { MeService } from "@odit/lfk-client-js";
|
import { MeService } from "@odit/lfk-client-js";
|
||||||
import Toastify from "toastify-js";
|
import Toastify from "toastify-js";
|
||||||
import ConfirmProfileDeletion from "./ConfirmProfileDeletion.svelte";
|
import ConfirmProfileDeletion from "./ConfirmProfileDeletion.svelte";
|
||||||
import PasswordStrength from "../auth/PasswordStrength.svelte";
|
import PasswordStrength, {password_strong_enough_and_equal} from "../auth/PasswordStrength.svelte";
|
||||||
$: data_loaded = false;
|
$: data_loaded = false;
|
||||||
$: delete_triggered = false;
|
$: delete_triggered = false;
|
||||||
$: original_data = {};
|
$: original_data = {};
|
||||||
@ -16,8 +16,7 @@
|
|||||||
JSON.stringify(editable) === JSON.stringify(original_data)
|
JSON.stringify(editable) === JSON.stringify(original_data)
|
||||||
);
|
);
|
||||||
$: save_enabled = changes_performed && isEmail(editable.email);
|
$: save_enabled = changes_performed && isEmail(editable.email);
|
||||||
$: update_password_enabled =
|
$: update_password_enabled = password_strong_enough_and_equal(password_change, password_confirm);
|
||||||
password_change.length > 0 && password_change === password_confirm;
|
|
||||||
const user_promise = MeService.meControllerGet().then((data) => {
|
const user_promise = MeService.meControllerGet().then((data) => {
|
||||||
data_loaded = true;
|
data_loaded = true;
|
||||||
data.groups = data.groups.map((g) => g.id);
|
data.groups = data.groups.map((g) => g.id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user