mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(web): admin and user signup forms (#7739)
This commit is contained in:
parent
46597aac97
commit
ffdd504008
2 changed files with 28 additions and 44 deletions
|
|
@ -6,9 +6,12 @@
|
|||
import Button from '../elements/buttons/button.svelte';
|
||||
import PasswordField from '../shared-components/password-field.svelte';
|
||||
|
||||
let errorMessage: string;
|
||||
let email = '';
|
||||
let password = '';
|
||||
let confirmPassword = '';
|
||||
let name = '';
|
||||
|
||||
let errorMessage: string;
|
||||
let canRegister = false;
|
||||
|
||||
$: {
|
||||
|
|
@ -21,25 +24,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
async function registerAdmin(event: SubmitEvent & { currentTarget: HTMLFormElement }) {
|
||||
async function registerAdmin() {
|
||||
if (canRegister) {
|
||||
errorMessage = '';
|
||||
|
||||
const form = new FormData(event.currentTarget);
|
||||
|
||||
const email = form.get('email');
|
||||
const password = form.get('password');
|
||||
const name = form.get('name');
|
||||
|
||||
try {
|
||||
await signUpAdmin({
|
||||
signUpDto: {
|
||||
email: String(email),
|
||||
password: String(password),
|
||||
name: String(name),
|
||||
},
|
||||
});
|
||||
|
||||
await signUpAdmin({ signUpDto: { email, password, name } });
|
||||
await goto(AppRoute.AUTH_LOGIN);
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to create admin account');
|
||||
|
|
@ -52,12 +42,12 @@
|
|||
<form on:submit|preventDefault={registerAdmin} method="post" class="mt-5 flex flex-col gap-5">
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="immich-form-label" for="email">Admin Email</label>
|
||||
<input class="immich-form-input" id="email" name="email" type="email" autocomplete="email" required />
|
||||
<input class="immich-form-input" id="email" bind:value={email} type="email" autocomplete="email" required />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="immich-form-label" for="password">Admin Password</label>
|
||||
<PasswordField id="password" name="password" bind:password autocomplete="new-password" />
|
||||
<PasswordField id="password" bind:password autocomplete="new-password" />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
|
|
@ -67,7 +57,7 @@
|
|||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="immich-form-label" for="name">Name</label>
|
||||
<input class="immich-form-input" id="name" name="name" type="text" autocomplete="name" required />
|
||||
<input class="immich-form-input" id="name" bind:value={name} type="text" autocomplete="name" required />
|
||||
</div>
|
||||
|
||||
{#if errorMessage}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue