diff --git a/src/astro-typesafe-api-caller.ts b/src/astro-typesafe-api-caller.ts index 18f06c89..3ae4241e 100644 --- a/src/astro-typesafe-api-caller.ts +++ b/src/astro-typesafe-api-caller.ts @@ -5,7 +5,12 @@ export const createCaller = createCallerFactory({ "klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"), "postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"), "unterlage": await import("../src/pages/api/unterlage.ts"), + "ausweise": await import("../src/pages/api/ausweise/index.ts"), + "bedarfsausweis-gewerbe/[id]": await import("../src/pages/api/bedarfsausweis-gewerbe/[id].ts"), + "bedarfsausweis-gewerbe": await import("../src/pages/api/bedarfsausweis-gewerbe/index.ts"), "aufnahme": await import("../src/pages/api/aufnahme/index.ts"), + "bedarfsausweis-wohnen/[id]": await import("../src/pages/api/bedarfsausweis-wohnen/[id].ts"), + "bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"), "admin/ausstellen": await import("../src/pages/api/admin/ausstellen.ts"), "admin/bedarfsausweis-ausstellen": await import("../src/pages/api/admin/bedarfsausweis-ausstellen.ts"), "admin/bestellbestaetigung": await import("../src/pages/api/admin/bestellbestaetigung.ts"), @@ -13,28 +18,23 @@ export const createCaller = createCallerFactory({ "admin/nicht-ausstellen": await import("../src/pages/api/admin/nicht-ausstellen.ts"), "admin/registriernummer": await import("../src/pages/api/admin/registriernummer.ts"), "admin/stornieren": await import("../src/pages/api/admin/stornieren.ts"), - "auth/access-token": await import("../src/pages/api/auth/access-token.ts"), - "auth/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"), - "auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"), - "ausweise": await import("../src/pages/api/ausweise/index.ts"), - "bedarfsausweis-wohnen/[id]": await import("../src/pages/api/bedarfsausweis-wohnen/[id].ts"), - "bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"), - "bedarfsausweis-gewerbe/[id]": await import("../src/pages/api/bedarfsausweis-gewerbe/[id].ts"), - "bedarfsausweis-gewerbe": await import("../src/pages/api/bedarfsausweis-gewerbe/index.ts"), "bilder/[id]": await import("../src/pages/api/bilder/[id].ts"), "geg-nachweis-gewerbe/[id]": await import("../src/pages/api/geg-nachweis-gewerbe/[id].ts"), "geg-nachweis-gewerbe": await import("../src/pages/api/geg-nachweis-gewerbe/index.ts"), "geg-nachweis-wohnen/[id]": await import("../src/pages/api/geg-nachweis-wohnen/[id].ts"), "geg-nachweis-wohnen": await import("../src/pages/api/geg-nachweis-wohnen/index.ts"), "objekt": await import("../src/pages/api/objekt/index.ts"), + "auth/access-token": await import("../src/pages/api/auth/access-token.ts"), + "auth/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"), + "auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"), "rechnung/[id]": await import("../src/pages/api/rechnung/[id].ts"), "rechnung/anfordern": await import("../src/pages/api/rechnung/anfordern.ts"), "rechnung": await import("../src/pages/api/rechnung/index.ts"), + "user": await import("../src/pages/api/user/index.ts"), + "user/self": await import("../src/pages/api/user/self.ts"), "ticket": await import("../src/pages/api/ticket/index.ts"), "verbrauchsausweis-wohnen/[id]": await import("../src/pages/api/verbrauchsausweis-wohnen/[id].ts"), "verbrauchsausweis-wohnen": await import("../src/pages/api/verbrauchsausweis-wohnen/index.ts"), - "user": await import("../src/pages/api/user/index.ts"), - "user/self": await import("../src/pages/api/user/self.ts"), "verbrauchsausweis-gewerbe/[id]": await import("../src/pages/api/verbrauchsausweis-gewerbe/[id].ts"), "verbrauchsausweis-gewerbe": await import("../src/pages/api/verbrauchsausweis-gewerbe/index.ts"), "webhooks/mollie": await import("../src/pages/api/webhooks/mollie.ts"), diff --git a/src/client/lib/spawnLoginPrompt.ts b/src/client/lib/spawnLoginPrompt.ts deleted file mode 100644 index c18e9381..00000000 --- a/src/client/lib/spawnLoginPrompt.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { dialogs } from "../../../svelte-dialogs.config"; -import { loginClient } from "#lib/login"; -import { addNotification } from "#components/Notifications/shared"; - -export async function spawnLoginPrompt() { - const result = await dialogs.prompt( - [ - { - label: "Email", - type: "email", - required: true, - placeholder: "Email", - name: "email" - }, - { - label: "Passwort", - type: "password", - name: "passwort", - required: true, - placeholder: "********", - }, - ], - { - title: "Login", - submitButtonText: "Einloggen", - cancelButtonText: "Abbrechen", - } - ); - - if (!result) return false; - - const [email, passwort] = result; - - const loginResult = await loginClient(email, passwort); - - if (loginResult === null) { - addNotification({ - type: "error", - message: "Einloggen fehlgeschlagen", - dismissable: true, - subtext: "Bitte überprüfen Sie ihre Eingaben und versuchen es erneut.", - timeout: 5000, - }) - - return false - } - - return true -} \ No newline at end of file diff --git a/src/client/lib/spawnSignupPrompt.ts b/src/client/lib/spawnSignupPrompt.ts deleted file mode 100644 index 80b7290e..00000000 --- a/src/client/lib/spawnSignupPrompt.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { dialogs } from "../../../svelte-dialogs.config.js"; -import { addNotification } from "#components/Notifications/shared.js"; -import { api } from "astro-typesafe-api/client"; - -export async function spawnSignupPrompt() { - const result = await dialogs.prompt( - [ - { - label: "Vorname", - type: "text", - required: true, - placeholder: "Vorname", - name: "vorname" - }, - { - label: "Name", - type: "text", - required: true, - placeholder: "Name", - name: "name" - }, - { - label: "Email", - type: "email", - required: true, - placeholder: "Email", - name: "email" - }, - { - label: "Passwort", - type: "password", - name: "passwort", - required: true, - placeholder: "********", - }, - ], - { - title: "Registrieren", - submitButtonText: "Registrieren", - cancelButtonText: "Abbrechen", - } - ); - - if (!result) return false; - - const [vorname, name, email, passwort] = result; - - try { - const response = await api.user.PUT.fetch({ - email, - passwort, - vorname, - name, - }); - - return true; - } catch(e) { - addNotification({ - type: "error", - message: "Registrieren fehlgeschlagen", - dismissable: true, - subtext: "Ein Fehler ist aufgetreten, vielleicht wird die angegebene Email bereits verwendet.", - timeout: 5000, - }) - return false; - } -} \ No newline at end of file diff --git a/src/lib/server/mail/registrierung.ts b/src/lib/server/mail/registrierung.ts index 445f3f14..5eb476ae 100644 --- a/src/lib/server/mail/registrierung.ts +++ b/src/lib/server/mail/registrierung.ts @@ -12,7 +12,7 @@ export async function sendRegisterMail( const verificationJwt = encodeToken({ typ: TokenType.Verify, exp: Date.now() + (15 * 60 * 1000), - uid: user.uid + id: user.id }) await transport.sendMail({ diff --git a/src/modules/EmbeddedRegisterModule.svelte b/src/modules/EmbeddedRegisterModule.svelte index 058f68a8..6dd6c21c 100644 --- a/src/modules/EmbeddedRegisterModule.svelte +++ b/src/modules/EmbeddedRegisterModule.svelte @@ -72,6 +72,7 @@ name="email" class="px-2.5 py-1.5 rounded-lg border bg-gray-50" bind:value={email} + on:keyup={() => (email = email.toLowerCase())} required /> diff --git a/src/modules/RegisterModule.svelte b/src/modules/RegisterModule.svelte index fa49eac4..9f415f9b 100644 --- a/src/modules/RegisterModule.svelte +++ b/src/modules/RegisterModule.svelte @@ -3,7 +3,6 @@ import { CrossCircled } from "radix-svelte-icons"; import { fade } from "svelte/transition"; import { api } from "astro-typesafe-api/client"; - import NotificationProvider from "#components/NotificationProvider/NotificationProvider.svelte"; import NotificationWrapper from "#components/Notifications/NotificationWrapper.svelte"; let passwort: string; @@ -13,10 +12,6 @@ export let redirect: string | null = null; - function handleInput(event) { - email = event.target.value.toLowerCase(); - } - async function login(e: SubmitEvent) { e.preventDefault() if (passwort.length < 8) { @@ -30,7 +25,7 @@ } try { - const { uid } = await api.user.PUT.fetch({ + const { id } = await api.user.PUT.fetch({ email, passwort, vorname, @@ -87,7 +82,7 @@ name="email" class="input input-bordered text-base text-base-content font-medium" bind:value={email} - on:input={handleInput} + on:keyup={() => (email = email.toLowerCase())} required />