diff --git a/default.cert b/default.cert new file mode 100644 index 00000000..cffe3c08 --- /dev/null +++ b/default.cert @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIIFCTCCAvGgAwIBAgIUbvD0dvnZOCfstZkE6ByRwYah4VMwDQYJKoZIhvcNAQEL +BQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTI0MTAxNjA4NDM0OFoXDTI1MTAx +NjA4NDM0OFowFDESMBAGA1UEAwwJbG9jYWxob3N0MIICIjANBgkqhkiG9w0BAQEF +AAOCAg8AMIICCgKCAgEApiFVMNAFtrai9s/xP+kYxsa7NzmPBlJg07MsFlW7JPek +FMAy/4HSSZd8gG3fWz73U3cy4J+Oecdy3O0T708ImVBcYskN/Hi/JCBuTRSJZqH4 +SlFFqoqR5E8H1bVDL9l4QQgWqoBzNiAEwBMlPSTAeoL91a02qYIPTNjVx93d+1Ua +eGq3/4HhYxogD6vjJOol32T2Twe7xMJ2j4IIsaQLvprA05HhYpJOxRkeuJQO7TEv +o5VcwxURtKm15z8GN6Fj0/MQ/edvj6l59g4ywtNeqIKyQHq/B9QVsfYQIK3HA9j/ +Z5cVEfvMjhMl2x6Bh29npg2DRWiucRJioEwRYsxP5G8DO6f0maP+siY8lZrrioxV +LVbyz4z6skFSoGR0lY59oe4+V4UR8Djww/WxuzmI8UJFT0/2cV1ux8mY/UAePjUo +HOzkUn7E669eabRldcBzWpb0ocmeufPdi+LWGHvZxE4v3iUVsxv+GgH7QAYy2LV3 +XW5PwHGEMbOkrb772oe13IEYiXCXKgPheI26u3dw6LUKk9V2w+aGvjfjY7IQMDZy +kZ6r5XdLeyUMYfu2UEs+8e8WTW+DYade35k9Hd2AWYYjoGeUjEoht1KKVA9cTyMg +Mf34u40bR5xb9TRLSZc9ZR3OBIIT3gea0gdNQ59XBwRHzcdW1bgOARFcYGcjWOkC +AwEAAaNTMFEwHQYDVR0OBBYEFJS1zAOTGWa0+TgIne/tFIk2h3dsMB8GA1UdIwQY +MBaAFJS1zAOTGWa0+TgIne/tFIk2h3dsMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI +hvcNAQELBQADggIBACAc9yR77JcUdFYPqVwwkm/hLPTKzcJCEgUZ/8MuYk8CEDxf +ZPeckksEaKHOCi4R6pUqGRudQ7+jW7z9+1zU4iS3s6TxoydTuIFIWlVWfvlCRtWi +CldfpHJH/fw8c7g0pV5neEMKmA1E2tNz8escjSqIDy8Ow8TUbZQvupId+izIg705 +gd5Bjb88WlGsEIEY7myIgU7MvSFwv2hogqUGomjJIv9dArOS3hDcLoFcL5Nb3W7/ +CqLgwOUPsLy+/bS8DvYe3Q6knPUmiPYA+jI0XNYmDqadrv00/5sYKEU27dKsu2RZ +GSD+M0cgxrDfO+hthlYVefak0edz0T3WYxVc+PFGmm6CjDd0Y2iCabaAID8RJzEf +GUwZRbrF0sQWWwvwxtMUvxvCY1I8N1gTFYaH6mDPPYPd72Cbu5UBtsOg1SHJ3WuE +rSUWgkjieQIS87kDMgFKcgrUUogkkivJhXy0dBWDQAZtHbG5qUuqypRlmGgST1zI +aRQD+tIR8aY6lsG8GAGXrSXA8YOyDHNwkR+7LpC6eNi96GDbOJdy6aF7qmJ3beRw +vP5MDwsITZp9BM3IofFQVS7MVEuPQ71plM/aqM5Jf0tqZFpzPN3S+udycyzHfPrK +5OBU6MSaClmyrsTjsh0TjCdOVZrX1nNvfg+2WlfzMn9XfQlpd+iXbjuShFuP +-----END CERTIFICATE----- diff --git a/frontend/src/lib/components/UserLandingPage.svelte b/frontend/src/lib/components/UserLandingPage.svelte index ea57db8b..4dd25e0f 100644 --- a/frontend/src/lib/components/UserLandingPage.svelte +++ b/frontend/src/lib/components/UserLandingPage.svelte @@ -1,21 +1,24 @@ -
- - -
- - Persönliche Daten -
- -
- -
- - Kinder -
- -
-
-
+{#if isVerifed === true} +
+ + +
+ + Persönliche Daten +
+ +
+ +
+ + Kinder +
+ +
+
+
+{:else} + +{/if} diff --git a/frontend/src/lib/components/UserLogin.svelte b/frontend/src/lib/components/UserLogin.svelte index 46bdcfa2..08dda067 100644 --- a/frontend/src/lib/components/UserLogin.svelte +++ b/frontend/src/lib/components/UserLogin.svelte @@ -1,102 +1,95 @@ {#if showAlert} { @@ -105,53 +98,43 @@ /> {/if} -{#if users.get()['loggedIn'] && users.get()['loggedIn'] !== null} - { - showAlert = false; - }} - /> -{:else} -
- - {#if heading} - {heading} - {/if} - -
- {#each data as element} - - {/each} - +
+ + {$_('login.heading')} - +
+ {#each formData as element} + + {/each} - - + - Not registered? - - Create account - -
-{/if} + + +
+ + Not registered? + + Create account + +
diff --git a/frontend/src/lib/components/UserProfile.svelte b/frontend/src/lib/components/UserProfile.svelte index 02153b7d..05bb301c 100644 --- a/frontend/src/lib/components/UserProfile.svelte +++ b/frontend/src/lib/components/UserProfile.svelte @@ -1,39 +1,68 @@ + {#if showAlert} + { + showAlert = false; + }} + /> + {/if} {#if userData !== null} -
-

{userData.name}

- +
+

{userData.email}

+
{:else}
- Willkommen! - + {$_('login.profileTitleDefault')} +
{/if} diff --git a/frontend/src/lib/components/UserRegistration.svelte b/frontend/src/lib/components/UserRegistration.svelte index c00ab672..8a3952e6 100644 --- a/frontend/src/lib/components/UserRegistration.svelte +++ b/frontend/src/lib/components/UserRegistration.svelte @@ -1,165 +1,155 @@ {#if showAlert} { showAlert = false; - missingValues = []; }} /> {/if} -
- - {#if heading} - {heading} - {/if} - -
+ + {$_('registration.heading')} + + + {#if success === false} + {#each data as element, i} {/each} + + - -
-
+ {:else} + + {/if} + diff --git a/frontend/src/lib/components/UserVerify.svelte b/frontend/src/lib/components/UserVerify.svelte new file mode 100644 index 00000000..f2d02943 --- /dev/null +++ b/frontend/src/lib/components/UserVerify.svelte @@ -0,0 +1,21 @@ + + +
+ +
+ {$_('registration.successMessage')} +
+
+ diff --git a/frontend/src/lib/stores/userStore.ts b/frontend/src/lib/stores/userStore.ts index 26821d87..aab5efb3 100644 --- a/frontend/src/lib/stores/userStore.ts +++ b/frontend/src/lib/stores/userStore.ts @@ -1,4 +1,6 @@ +import { type UserRead } from '$lib/client/types.gen'; import { BasicStore } from '$lib/stores/basicStore'; +import { writable } from 'svelte/store'; interface UserData { name: string; @@ -86,4 +88,6 @@ async function hash(input: string): string { return hash; } -export { createDummyUser, hash, users, UserStore, type UserData, type UserList }; +const currentUser = writable(null as null | UserRead); + +export { createDummyUser, currentUser, hash, users, UserStore, type UserData, type UserList }; diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index c852a1ab..533c522e 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -1,7 +1,4 @@ { - "login": { - "LOGIN_BAD_CREDENTIALS": "Ungültige E-Mail-Adresse oder ungültiges Passwort" - }, "milestone": { "answer0-text": "Noch gar nicht", "answer0-desc": "Das Kind macht noch keine Anstalten bzw. ist noch nicht in der Lage, das Verhalten auszuführen.", @@ -40,7 +37,44 @@ "image": "Bild", "images": "Bilder" }, - "login": {}, + "registration": { + "heading": "Als neuer Benutzer registrieren", + "alertMessageMissing": "Bitte füllen Sie alle Felder aus.", + "alertMessageError": "Ein Fehler ist aufgetreten", + "alertMessagePasswords": "Passwörter stimmen nicht überein", + "alertMessageTitle": "Fehler", + "usernameLabel": "Benutzername", + "passwordLabel": "Passwort", + "emailLabel": "E-Mail", + "passwordConfirmLabel": "Passwort wiederholen", + "role": "Rolle", + "observerRole": "Beobachter", + "researcherRole": "Wissenschaftler", + "adminRole": "Admin", + "submitButtonLabel": "Absenden", + "selectPlaceholder": "Bitte auswählen", + "successMessage": "Bitte überprüfen sie ihr E-Mail Postfach", + "goHome": "Zur Hauptseite" + }, + "login": { + "heading": "Einloggen", + "alreadyLoggedInMessage": "Sie sind bereits angemeldet. Melden sie sich zuerst ab um den Account zu wechseln.", + "alertMessageTitle": "Fehler", + "badCredentials": "Ungültige E-Mail-Adresse oder ungültiges Passwort", + "badActiveUser": "Der Benutzer konnte nicht gefunden werden", + "unauthorized": "Zugang verweigert", + "usernameLabel": "Benutzerkennung", + "passwordLabel": "Passwort", + "role": "Rolle", + "observerRole": "Beobachter", + "researcherRole": "Wissenschaftler", + "adminRole": "Admin", + "submitButtonLabel": "Absenden", + "selectPlaceholder": "Bitte auswählen", + "profileButtonLabelDefault": "Einloggen oder Registrieren", + "profileButtonLabelLogout": "Logout", + "profileTitleDefault": "Willkommen!" + }, "forgotPw": { "heading": "Passwort vergessen?", "placeholder": "Bitte geben sie eine E-mail Adresse an um ihr Passwort zu erneuern", diff --git a/frontend/src/routes/userLand/userLogin/+page.svelte b/frontend/src/routes/userLand/userLogin/+page.svelte index c007e1d8..e14b2ca2 100644 --- a/frontend/src/routes/userLand/userLogin/+page.svelte +++ b/frontend/src/routes/userLand/userLogin/+page.svelte @@ -1,41 +1,5 @@ - + diff --git a/frontend/src/routes/userLand/userRegistration/+page.svelte b/frontend/src/routes/userLand/userRegistration/+page.svelte index d78aef9f..104f34b5 100644 --- a/frontend/src/routes/userLand/userRegistration/+page.svelte +++ b/frontend/src/routes/userLand/userRegistration/+page.svelte @@ -1,57 +1,5 @@ - + diff --git a/mondey_backend/src/mondey_backend/users.py b/mondey_backend/src/mondey_backend/users.py index 91a394df..da5a0823 100644 --- a/mondey_backend/src/mondey_backend/users.py +++ b/mondey_backend/src/mondey_backend/users.py @@ -1,3 +1,6 @@ +# TODO: 17th Oct. 2024: remove the artificial verification setting again as soon as +# the email verification server has been implemented. See 'README' block @ line 33f + from __future__ import annotations from typing import Annotated @@ -15,6 +18,7 @@ from .databases.users import AccessToken from .databases.users import User +from .databases.users import async_session_maker from .databases.users import get_access_token_db from .databases.users import get_user_db from .settings import app_settings @@ -25,7 +29,18 @@ class UserManager(IntegerIDMixin, BaseUserManager[User, int]): verification_token_secret = app_settings.SECRET async def on_after_register(self, user: User, request: Request | None = None): - print(f"User {user.id} has registered.") + # README: Sets the verified flag artificially to allow users to work without an + # actual verification process for now. this can go again as soon as we have an email server for verification. + async with async_session_maker() as session: + user_db = await session.get(User, user.id) + if user_db: + user_db.is_verified = True + await session.commit() + await session.refresh(user_db) + + print(f"User {user_db.id} has registered.") + print(f"User is verified? {user_db.is_verified}") + # end README async def on_after_forgot_password( self, user: User, token: str, request: Request | None = None