1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-28 05:18:38 +02:00

Use cookies for client requests (#377)

* Use cookie for frontend request

* Remove api helper to use SDK

* Added error handling to status box

* Remove additional places that check for session.user

* Refactor sending password

* prettier clean up

* remove deadcode

* Move all authentication requests to the client

* refactor upload panel to only fetch assets after the upload panel disappear

* Added keydown to remove focus on title change on album viewer
This commit is contained in:
Alex
2022-07-26 12:28:07 -05:00
committed by GitHub
parent 2ebb755f00
commit 83cbf51704
54 changed files with 4954 additions and 4540 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { sendRegistrationForm } from '$lib/auth-api';
import { api } from '@api';
import { createEventDispatcher } from 'svelte';
let error: string;
@ -22,21 +22,33 @@
const dispatch = createEventDispatcher();
async function registerUser(event: SubmitEvent) {
console.log('registerUser');
if (canCreateUser) {
error = '';
const formElement = event.target as HTMLFormElement;
const response = await sendRegistrationForm(formElement);
const form = new FormData(formElement);
if (response.error) {
error = JSON.stringify(response.error);
}
const email = form.get('email');
const password = form.get('password');
const firstName = form.get('firstName');
const lastName = form.get('lastName');
if (response.success) {
const { status } = await api.userApi.createUser({
email: String(email),
password: String(password),
firstName: String(firstName),
lastName: String(lastName)
});
if (status === 201) {
success = 'New user created';
dispatch('user-created');
return;
} else {
error = 'Error create user account';
}
}
}
@ -47,11 +59,12 @@
<img class="text-center" src="/immich-logo.svg" height="100" width="100" alt="immich-logo" />
<h1 class="text-2xl text-immich-primary font-medium">Create new user</h1>
<p class="text-sm border rounded-md p-4 font-mono text-gray-600">
Please provide your user with the password, they will have to change it on their first sign in.
Please provide your user with the password, they will have to change it on their first sign
in.
</p>
</div>
<form on:submit|preventDefault={registerUser} method="post" action="/admin/api/create-user" autocomplete="off">
<form on:submit|preventDefault={registerUser} autocomplete="off">
<div class="m-4 flex flex-col gap-2">
<label class="immich-form-label" for="email">Email</label>
<input class="immich-form-input" id="email" name="email" type="email" required />
@ -59,7 +72,14 @@
<div class="m-4 flex flex-col gap-2">
<label class="immich-form-label" for="password">Password</label>
<input class="immich-form-input" id="password" name="password" type="password" required bind:value={password} />
<input
class="immich-form-input"
id="password"
name="password"
type="password"
required
bind:value={password}
/>
</div>
<div class="m-4 flex flex-col gap-2">