Skip to content

Commit

Permalink
Update password reset form and add more localization for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmorley15 committed Dec 14, 2024
1 parent c0fd91e commit 4839edd
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 35 deletions.
3 changes: 2 additions & 1 deletion frontend/src/lib/components/CategoryDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
bind:value={new_category.icon}
/>
<button on:click={toggleEmojiPicker} type="button" class="btn btn-secondary">
{isEmojiPickerVisible ? 'Hide' : 'Show'} Emoji Picker
{isEmojiPickerVisible ? $t('adventures.hide') : $t('adventures.hide')}
{$t('adventures.emoji_picker')}
</button>
<button on:click={custom_category} type="button" class="btn btn-primary">
{$t('adventures.add')}
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@
"category_fetch_error": "Fehler beim Abrufen der Kategorien",
"copied_to_clipboard": "In die Zwischenablage kopiert!",
"copy_failed": "Das Kopieren ist fehlgeschlagen",
"adventure_calendar": "Abenteuerkalender"
"adventure_calendar": "Abenteuerkalender",
"emoji_picker": "Emoji-Picker",
"hide": "Verstecken",
"show": "Zeigen"
},
"home": {
"desc_1": "Entdecken, planen und erkunden Sie mit Leichtigkeit",
Expand Down Expand Up @@ -255,7 +258,10 @@
"profile_picture": "Profilbild",
"public_profile": "Öffentliches Profil",
"public_tooltip": "Mit einem öffentlichen Profil können Benutzer Sammlungen mit Ihnen teilen und Ihr Profil auf der Benutzerseite anzeigen.",
"email_required": "E-Mail ist erforderlich"
"email_required": "E-Mail ist erforderlich",
"both_passwords_required": "Beide Passwörter sind erforderlich",
"new_password": "Neues Passwort",
"reset_failed": "Passwort konnte nicht zurückgesetzt werden"
},
"users": {
"no_users_found": "Keine Benutzer mit öffentlichen Profilen gefunden."
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@
"nothing_planned": "Nothing planned for this day. Enjoy the journey!",
"copied_to_clipboard": "Copied to clipboard!",
"copy_failed": "Copy failed",
"show": "Show",
"hide": "Hide",
"emoji_picker": "Emoji Picker",
"days": "days",
"activities": {
"general": "General 🌍",
Expand Down Expand Up @@ -266,7 +269,10 @@
"profile_picture": "Profile Picture",
"public_profile": "Public Profile",
"public_tooltip": "With a public profile, users can share collections with you and view your profile on the users page.",
"email_required": "Email is required"
"email_required": "Email is required",
"new_password": "New Password",
"both_passwords_required": "Both passwords are required",
"reset_failed": "Failed to reset password"
},
"users": {
"no_users_found": "No users found with public profiles."
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@
"category_fetch_error": "Error al buscar categorías",
"copied_to_clipboard": "¡Copiado al portapapeles!",
"copy_failed": "Copia fallida",
"adventure_calendar": "Calendario de aventuras"
"adventure_calendar": "Calendario de aventuras",
"emoji_picker": "Selector de emojis",
"hide": "Esconder",
"show": "Espectáculo"
},
"worldtravel": {
"all": "Todo",
Expand Down Expand Up @@ -266,7 +269,10 @@
"profile_picture": "Foto de perfil",
"public_profile": "Perfil público",
"public_tooltip": "Con un perfil público, los usuarios pueden compartir colecciones con usted y ver su perfil en la página de usuarios.",
"email_required": "Se requiere correo electrónico"
"email_required": "Se requiere correo electrónico",
"both_passwords_required": "Se requieren ambas contraseñas",
"new_password": "Nueva contraseña",
"reset_failed": "No se pudo restablecer la contraseña"
},
"users": {
"no_users_found": "No se encontraron usuarios con perfiles públicos."
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@
"category_fetch_error": "Erreur lors de la récupération des catégories",
"copied_to_clipboard": "Copié dans le presse-papier !",
"copy_failed": "Échec de la copie",
"adventure_calendar": "Calendrier d'aventure"
"adventure_calendar": "Calendrier d'aventure",
"emoji_picker": "Sélecteur d'émoticônes",
"hide": "Cacher",
"show": "Montrer"
},
"home": {
"desc_1": "Découvrez, planifiez et explorez en toute simplicité",
Expand Down Expand Up @@ -255,7 +258,10 @@
"profile_picture": "Photo de profil",
"public_profile": "Profil public",
"public_tooltip": "Avec un profil public, les utilisateurs peuvent partager des collections avec vous et afficher votre profil sur la page des utilisateurs.",
"email_required": "L'e-mail est requis"
"email_required": "L'e-mail est requis",
"both_passwords_required": "Les deux mots de passe sont requis",
"new_password": "Nouveau mot de passe",
"reset_failed": "Échec de la réinitialisation du mot de passe"
},
"users": {
"no_users_found": "Aucun utilisateur trouvé avec des profils publics."
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@
"category_fetch_error": "Errore durante il recupero delle categorie",
"copied_to_clipboard": "Copiato negli appunti!",
"copy_failed": "Copia non riuscita",
"adventure_calendar": "Calendario delle avventure"
"adventure_calendar": "Calendario delle avventure",
"emoji_picker": "Selettore di emoji",
"hide": "Nascondere",
"show": "Spettacolo"
},
"home": {
"desc_1": "Scopri, pianifica ed esplora con facilità",
Expand Down Expand Up @@ -255,7 +258,10 @@
"profile_picture": "Immagine del profilo",
"public_profile": "Profilo pubblico",
"public_tooltip": "Con un profilo pubblico, gli utenti possono condividere raccolte con te e visualizzare il tuo profilo nella pagina degli utenti.",
"email_required": "L'e-mail è obbligatoria"
"email_required": "L'e-mail è obbligatoria",
"both_passwords_required": "Sono necessarie entrambe le password",
"new_password": "Nuova parola d'ordine",
"reset_failed": "Impossibile reimpostare la password"
},
"users": {
"no_users_found": "Nessun utente trovato con profili pubblici."
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@
"category_fetch_error": "Fout bij ophalen van categorieën",
"copied_to_clipboard": "Gekopieerd naar klembord!",
"copy_failed": "Kopiëren mislukt",
"adventure_calendar": "Avonturenkalender"
"adventure_calendar": "Avonturenkalender",
"emoji_picker": "Emoji-kiezer",
"hide": "Verbergen",
"show": "Show"
},
"home": {
"desc_1": "Ontdek, plan en verken met gemak",
Expand Down Expand Up @@ -255,7 +258,10 @@
"profile_picture": "Profielfoto",
"public_profile": "Openbaar profiel",
"public_tooltip": "Met een openbaar profiel kunnen gebruikers collecties met u delen en uw profiel bekijken op de gebruikerspagina.",
"email_required": "E-mail is vereist"
"email_required": "E-mail is vereist",
"both_passwords_required": "Beide wachtwoorden zijn vereist",
"new_password": "Nieuw wachtwoord",
"reset_failed": "Kan het wachtwoord niet opnieuw instellen"
},
"users": {
"no_users_found": "Er zijn geen gebruikers gevonden met openbare profielen."
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@
},
"copied_to_clipboard": "Skopiowano do schowka!",
"copy_failed": "Kopiowanie nie powiodło się",
"adventure_calendar": "Kalendarz przygód"
"adventure_calendar": "Kalendarz przygód",
"emoji_picker": "Wybór emoji",
"hide": "Ukrywać",
"show": "Pokazywać"
},
"worldtravel": {
"country_list": "Lista krajów",
Expand Down Expand Up @@ -266,7 +269,10 @@
"profile_picture": "Zdjęcie profilowe",
"public_profile": "Publiczny profil",
"public_tooltip": "Dzięki publicznemu profilowi użytkownicy mogą dzielić się z Tobą kolekcjami i oglądać Twój profil na stronie użytkowników.",
"email_required": "Adres e-mail jest wymagany"
"email_required": "Adres e-mail jest wymagany",
"both_passwords_required": "Obydwa hasła są wymagane",
"new_password": "Nowe hasło",
"reset_failed": "Nie udało się zresetować hasła"
},
"users": {
"no_users_found": "Nie znaleziono użytkowników z publicznymi profilami."
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@
"category_fetch_error": "Det gick inte att hämta kategorier",
"copied_to_clipboard": "Kopierat till urklipp!",
"copy_failed": "Kopieringen misslyckades",
"adventure_calendar": "Äventyrskalender"
"adventure_calendar": "Äventyrskalender",
"emoji_picker": "Emoji-väljare",
"hide": "Dölja",
"show": "Visa"
},
"home": {
"desc_1": "Upptäck, planera och utforska med lätthet",
Expand Down Expand Up @@ -266,7 +269,10 @@
"public_tooltip": "Med en offentlig profil kan användare dela samlingar med dig och se din profil på användarsidan.",
"profile_picture": "Profilbild",
"public_profile": "Offentlig profil",
"email_required": "E-post krävs"
"email_required": "E-post krävs",
"both_passwords_required": "Båda lösenorden krävs",
"new_password": "Nytt lösenord",
"reset_failed": "Det gick inte att återställa lösenordet"
},
"users": {
"no_users_found": "Inga användare hittades med offentliga profiler."
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@
"category_fetch_error": "获取类别时出错",
"copied_to_clipboard": "已复制到剪贴板!",
"copy_failed": "复制失败",
"adventure_calendar": "冒险日历"
"adventure_calendar": "冒险日历",
"emoji_picker": "表情符号选择器",
"hide": "隐藏",
"show": "展示"
},
"home": {
"desc_1": "轻松发现、规划和探索",
Expand Down Expand Up @@ -255,7 +258,10 @@
"profile_picture": "个人资料图片",
"public_profile": "公开资料",
"public_tooltip": "通过公开个人资料,用户可以与您共享收藏并在用户页面上查看您的个人资料。",
"email_required": "电子邮件为必填项"
"email_required": "电子邮件为必填项",
"both_passwords_required": "两个密码都需要",
"new_password": "新密码",
"reset_failed": "重置密码失败"
},
"worldtravel": {
"all": "全部",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/collections/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
import type { Adventure, Collection } from '$lib/types';

import type { Actions, RequestEvent } from '@sveltejs/kit';
import { fetchCSRFToken, tryRefreshToken } from '$lib/index.server';
import { fetchCSRFToken } from '$lib/index.server';
import { checkLink } from '$lib';

const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/collections/[id]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const load = (async (event) => {
}) satisfies PageServerLoad;

import type { Actions } from '@sveltejs/kit';
import { fetchCSRFToken, tryRefreshToken } from '$lib/index.server';
import { fetchCSRFToken } from '$lib/index.server';

const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/routes/user/reset-password/[key]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export const actions: Actions = {
const key = event.params.key;

if (!password || !confirm_password) {
return fail(400, { message: 'both_passwords_required' });
return fail(400, { message: 'auth.both_passwords_required' });
}

if (password !== confirm_password) {
return fail(400, { message: 'passwords_not_match' });
return fail(400, { message: 'settings.password_does_not_match' });
}

const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
Expand All @@ -47,7 +47,7 @@ export const actions: Actions = {
const error_message = await response.json();
console.error(error_message);
console.log(response);
return fail(response.status, { message: 'reset_failed' });
return fail(response.status, { message: 'auth.reset_failed' });
}

return redirect(302, '/login');
Expand Down
30 changes: 18 additions & 12 deletions frontend/src/routes/user/reset-password/[key]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,40 @@

<h1 class="text-center font-bold text-4xl mb-4">{$t('settings.change_password')}</h1>

<form method="POST" use:enhance>
<div class="mb-4">
<label for="password" class="block mb-2">{$t('auth.new_password')}</label>
<form method="POST" use:enhance class="flex flex-col items-center justify-center space-y-4">
<div class="w-full max-w-xs">
<label for="password" class="label">
<span class="label-text">{$t('auth.new_password')}</span>
</label>
<input
type="password"
id="password"
name="password"
required
class="w-full p-2 border rounded"
class="input input-bordered w-full"
/>
</div>
<div class="mb-4">
<label for="confirm_password" class="block mb-2">{$t('auth.confirm_password')}</label>

<div class="w-full max-w-xs">
<label for="confirm_password" class="label">
<span class="label-text">{$t('auth.confirm_password')}</span>
</label>
<input
type="password"
id="confirm_password"
name="confirm_password"
required
class="w-full p-2 border rounded"
class="input input-bordered w-full"
/>
</div>
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded"
>{$t('auth.reset_password')}</button
>

<button type="submit" class="btn btn-primary">
{$t('settings.reset_password')}
</button>

{#if $page.form?.message}
<div class="text-center text-error mt-4">
{$page.form?.message}
<div class="text-error">
{$t($page.form?.message)}
</div>
{/if}
</form>
Expand Down

0 comments on commit 4839edd

Please sign in to comment.