From 98bc810e515fc04192e6058e0dce272a2e34e76a Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 19 Dec 2020 19:00:54 +0100 Subject: [PATCH] PwReset view --- package.json | 3 +- src/App.svelte | 1 + src/components/ForgotPassword.svelte | 179 ++++++++++++++++----------- src/components/Tracks.svelte | 1 + src/locales/de.json | 5 +- src/locales/en.json | 5 +- 6 files changed, 121 insertions(+), 73 deletions(-) diff --git a/package.json b/package.json index d5f35af7..651103ee 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "@odit/lfk-client-js": "^0.0.4", "svelte-i18n": "^3.3.0", "svelte-spa-router": "^3.1.0", - "toastify-js": "^1.9.3" + "toastify-js": "^1.9.3", + "validator": "^13.5.2" }, "devDependencies": { "svelte": "^3.29.7", diff --git a/src/App.svelte b/src/App.svelte index e1e7bd87..11531577 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -36,6 +36,7 @@ "/forgot_password": ForgotPassword, "/dashboard": wrap({ component: Dashboard, conditions: [checkAuth] }), "/": wrap({ component: Dashboard, conditions: [checkAuth] }), + // "/password_reset_sent/*": Book, // Using named parameters, with last being optional // "/author/:first/:last?": Author, diff --git a/src/components/ForgotPassword.svelte b/src/components/ForgotPassword.svelte index 41a6cd39..2503222c 100644 --- a/src/components/ForgotPassword.svelte +++ b/src/components/ForgotPassword.svelte @@ -5,89 +5,128 @@ import { push, pop, replace } from "svelte-spa-router"; // import { OpenAPI, AuthService } from "@odit/lfk-client-js"; - OpenAPI.BASE = "http://localhost:4010"; + import isEmail from "validator/es/lib/isEmail"; + // import Toastify from "toastify-js"; import "toastify-js/src/toastify.css"; - let usersUsername = ""; + let reset_mail_sent = false; + let usersEmail = ""; function reset() { - Toastify({ - text: "mail validation in progress...", - duration: 3500, - }).showToast(); + if (isEmail(usersEmail)) { + Toastify({ + text: $_("mail-validation-in-progress"), + duration: 3500, + }).showToast(); + reset_mail_sent = true; + } else { + Toastify({ + text: $_('invalid-mail-reset'), + duration: 3500, + }).showToast(); + } } -
-
- -

- {$_('application_name')} -

-

- {$_('forgot_password?')} -

-

- {$_('dont-panic-were-resetting-it')} -

-
-
-
- -
-
- -
- -
+{#if reset_mail_sent} +
+
+ +

+ {$_('application_name')} +

+

+ Passwort-Reset Mail wurde an + {usersEmail} + geschickt +

-
-
-
-
-
- {$_('dont-have-your-email-connected')} -
-
- {$_('cannot-reset-your-password-directly')} -
-
+{:else} +
+
+ +

+ {$_('application_name')} +

+

+ {$_('forgot_password?')} +

+

+ {$_('dont-panic-were-resetting-it')} +

+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ {$_('dont-have-your-email-connected')} +
+
+ {$_('cannot-reset-your-password-directly')} + + +
+
+
+
+{/if} diff --git a/src/components/Tracks.svelte b/src/components/Tracks.svelte index 0f833042..030dc336 100644 --- a/src/components/Tracks.svelte +++ b/src/components/Tracks.svelte @@ -19,6 +19,7 @@
    {#each tracks as item} +
  • {item.name}
  • {item.distance}
  • {/each}
diff --git a/src/locales/de.json b/src/locales/de.json index 075be8ae..37a89cf1 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -18,5 +18,8 @@ "register": "Registrieren", "send-a-mail-to-lfk-odit-services": "Sende eine Mail an lfk@odit.services", "dont-panic-were-resetting-it": "Keine Panik, wir setzen es zurück ✌", - "dont-have-your-email-connected": "Deine E-Mail ist nicht verknüpft?" + "dont-have-your-email-connected": "Deine E-Mail ist nicht verknüpft?", + "reset-my-password": "Passwort zurücksetzen", + "e-mail-adress": "E-Mail-Adresse", + "invalid-mail-reset": "Das ist keine gültige E-Mail" } diff --git a/src/locales/en.json b/src/locales/en.json index 49884d82..c25c6928 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -21,5 +21,8 @@ "cannot-reset-your-password-directly": "Bummer. We unfortunately cannot reset your password directly. Please send us a mail and confirm your identity", "send-a-mail-to-lfk-odit-services": "send a mail to lfk@odit.services", "dont-have-your-email-connected": "Don't have your email connected?", - "dont-panic-were-resetting-it": "Don't panic, we're resetting it ✌" + "dont-panic-were-resetting-it": "Don't panic, we're resetting it ✌", + "e-mail-adress": "E-Mail Adress", + "mail-validation-in-progress": "mail validation in progress...", + "invalid-mail-reset": "the provided email is invalid" }