Reset can now only be triggered if pw is strong enoug

ref #106
This commit is contained in:
Nicolai Ort 2021-03-26 19:47:26 +01:00
parent b2509e9e53
commit 75d8f7331b

View File

@ -3,20 +3,24 @@
import { _ } from "svelte-i18n";
import Toastify from "toastify-js";
import "toastify-js/src/toastify.css";
import PasswordStrength from "../auth/PasswordStrength.svelte";
import PasswordStrength, {
password_strong_enough,
} from "../auth/PasswordStrength.svelte";
let state = "reset_in_progress";
let password = "";
export let params;
function set_new_password() {
if (password.trim() !== "") {
Toastify({
text: $_('password-reset-in-progress'),
text: $_("password-reset-in-progress"),
duration: 3500,
}).showToast();
AuthService.authControllerResetPassword(atob(params.resetkey),{ password })
AuthService.authControllerResetPassword(atob(params.resetkey), {
password,
})
.then((resp) => {
Toastify({
text: $_('password-reset-successful'),
text: $_("password-reset-successful"),
duration: 3500,
}).showToast();
state = "reset_success";
@ -26,14 +30,14 @@
});
} else {
Toastify({
text: $_('please-provide-a-password'),
text: $_("please-provide-a-password"),
duration: 3500,
}).showToast();
}
}
</script>
{#if state==="reset_success"}
{#if state === 'reset_success'}
<div class="min-h-screen flex items-center justify-center bg-gray-100">
<div class="max-w-md w-full py-12 px-6">
<img style="height:10rem;" class="mx-auto" src="/lfk-logo.png" alt="" />
@ -57,7 +61,7 @@
</div>
</div>
</div>
{:else if state==="reset_error"}
{:else if state === 'reset_error'}
<div class="min-h-screen flex items-center justify-center bg-gray-100">
<div class="max-w-md w-full py-12 px-6">
<img style="height:10rem;" class="mx-auto" src="/lfk-logo.png" alt="" />
@ -81,7 +85,7 @@
</div>
</div>
</div>
{:else if state==="reset_in_progress"}
{:else if state === 'reset_in_progress'}
<div class="min-h-screen flex items-center justify-center bg-gray-100">
<div class="max-w-md w-full py-12 px-6">
<img style="height:10rem;" class="mx-auto" src="/lfk-logo.png" alt="" />
@ -109,6 +113,8 @@
<div class="mt-5">
<button
on:click={set_new_password}
disabled={!password_strong_enough(password)}
class:opacity-50={!password_strong_enough(password)}
type="submit"
class="relative block w-full py-2 px-3 border border-transparent rounded-md text-white font-semibold bg-gray-800 hover:bg-gray-700 focus:bg-gray-900 focus:outline-none focus:shadow-outline sm:text-sm">
<span class="absolute left-0 inset-y pl-3">