Add reset i18n

This commit is contained in:
Restray 2022-04-02 23:57:37 +02:00
parent c1c25d59c8
commit 13891110ce
No known key found for this signature in database
GPG Key ID: 67C6DEF95A4DC812
4 changed files with 21 additions and 12 deletions

View File

@ -63,14 +63,20 @@
"type": "Type", "type": "Type",
"html_url": "HTML URL", "html_url": "HTML URL",
"api_url": "API URL", "api_url": "API URL",
"organization": "Organization" "organization": "Organization",
"new_password": "New password",
"super_secure_new_password": "Super secure new password",
"submit": "Submit"
}, },
"register": { "register": {
"register": "Register", "register": "Register",
"first_user": "You are registering the first user. It will be the administrator of your Coolify instance." "first_user": "You are registering the first user. It will be the administrator of your Coolify instance."
}, },
"reset": { "reset": {
"reset_password": "Reset password" "reset_password": "Reset",
"invalid_secret_key": "Invalid secret key.",
"secret_key": "Secret Key",
"find_path_secret_key": "You can find it in ~/coolify/.env (COOLIFY_SECRET_KEY)"
}, },
"application": { "application": {
"configuration": { "configuration": {

View File

@ -1,5 +1,6 @@
import type { RequestHandler } from '@sveltejs/kit'; import type { RequestHandler } from '@sveltejs/kit';
import * as db from '$lib/database'; import * as db from '$lib/database';
import { t } from '$lib/translations';
export const get: RequestHandler = async () => { export const get: RequestHandler = async () => {
const users = await db.prisma.user.findMany({}); const users = await db.prisma.user.findMany({});
@ -16,7 +17,7 @@ export const post: RequestHandler = async (event) => {
return { return {
status: 500, status: 500,
body: { body: {
error: 'Invalid secret key.' error: t.get('reset.invalid_secret_key')
} }
}; };
} }

View File

@ -3,6 +3,7 @@
import { get, post } from '$lib/api'; import { get, post } from '$lib/api';
import CopyPasswordField from '$lib/components/CopyPasswordField.svelte'; import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';
import { errorNotification } from '$lib/form'; import { errorNotification } from '$lib/form';
import { t } from '$lib/translations';
import { toast } from '@zerodevx/svelte-toast'; import { toast } from '@zerodevx/svelte-toast';
let secretKey; let secretKey;
@ -48,14 +49,14 @@
<line x1="5" y1="12" x2="11" y2="6" /> <line x1="5" y1="12" x2="11" y2="6" />
</svg> </svg>
</div> </div>
<div class="pb-10 pt-24 text-center text-4xl font-bold">Reset Password</div> <div class="pb-10 pt-24 text-center text-4xl font-bold">{$t('reset.reset_password')}</div>
<div class="flex items-center justify-center"> <div class="flex items-center justify-center">
{#if password} {#if password}
<table class="mx-2 text-left"> <table class="mx-2 text-left">
<thead class="mb-2"> <thead class="mb-2">
<tr> <tr>
<th class="px-2">Email</th> <th class="px-2">{$t('forms.email')}</th>
<th>New password</th> <th>{$t('forms.new_password')}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -67,11 +68,11 @@
id="newPassword" id="newPassword"
name="newPassword" name="newPassword"
bind:value={user.newPassword} bind:value={user.newPassword}
placeholder="Super secure new password" placeholder={$t('forms.super_secure_new_password')}
/> />
<button <button
class="mx-auto my-4 w-32 bg-coollabs hover:bg-coollabs-100" class="mx-auto my-4 w-32 bg-coollabs hover:bg-coollabs-100"
on:click={() => resetPassword(user)}>Reset</button on:click={() => resetPassword(user)}>{$t('reset.reset_password')}</button
></td ></td
> >
</tr> </tr>
@ -80,16 +81,16 @@
</table> </table>
{:else} {:else}
<form class="flex flex-col" on:submit|preventDefault={handleSubmit}> <form class="flex flex-col" on:submit|preventDefault={handleSubmit}>
<div class="text-center text-2xl py-2 font-bold">Secret Key</div> <div class="text-center text-2xl py-2 font-bold">{$t('reset.secret_key')}</div>
<CopyPasswordField <CopyPasswordField
isPasswordField={true} isPasswordField={true}
id="secretKey" id="secretKey"
name="secretKey" name="secretKey"
bind:value={secretKey} bind:value={secretKey}
placeholder="You can find it in ~/coolify/.env (COOLIFY_SECRET_KEY)" placeholder={$t('reset.find_path_secret_key')}
/> />
<button type="submit" class="bg-coollabs hover:bg-coollabs-100 mx-auto w-32 my-4" <button type="submit" class="bg-coollabs hover:bg-coollabs-100 mx-auto w-32 my-4"
>Submit</button >{$t('forms.submit')}</button
> >
</form> </form>
{/if} {/if}

View File

@ -1,6 +1,7 @@
import type { RequestHandler } from '@sveltejs/kit'; import type { RequestHandler } from '@sveltejs/kit';
import * as db from '$lib/database'; import * as db from '$lib/database';
import { ErrorHandler, hashPassword } from '$lib/database'; import { ErrorHandler, hashPassword } from '$lib/database';
import { t } from '$lib/translations';
export const post: RequestHandler = async (event) => { export const post: RequestHandler = async (event) => {
const { secretKey, user } = await event.request.json(); const { secretKey, user } = await event.request.json();
@ -8,7 +9,7 @@ export const post: RequestHandler = async (event) => {
return { return {
status: 500, status: 500,
body: { body: {
error: 'Invalid secret key.' error: t.get('reset.invalid_secret_key')
} }
}; };
} }