1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-05 05:05:17 +02:00

Update password reset form and add more localization for error messages

This commit is contained in:
Sean Morley 2024-12-14 13:36:15 -05:00
parent c0fd91ef8d
commit 4839edde7b
14 changed files with 96 additions and 35 deletions

View file

@ -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'];
@ -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');

View file

@ -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>