1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

chore(web): remove createEventDispatcher from LoginForm (#7177)

This commit is contained in:
Ben McCann 2024-02-18 10:47:13 -08:00 committed by GitHub
parent 857ec0451d
commit 3480fe5326
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 14 deletions

View file

@ -6,10 +6,14 @@
import { oauth } from '$lib/utils';
import { getServerErrorMessage, handleError } from '$lib/utils/handle-error';
import { getServerConfig, login } from '@immich/sdk';
import { createEventDispatcher, onMount } from 'svelte';
import { onMount } from 'svelte';
import { fade } from 'svelte/transition';
import Button from '../elements/buttons/button.svelte';
export let onSuccess: () => unknown | Promise<unknown>;
export let onFirstLogin: () => unknown | Promise<unknown>;
export let onOnboarding: () => unknown | Promise<unknown>;
let errorMessage: string;
let email = '';
let password = '';
@ -17,12 +21,6 @@
let loading = false;
let oauthLoading = true;
const dispatch = createEventDispatcher<{
success: void;
firstLogin: void;
onboarding: void;
}>();
onMount(async () => {
if (!$featureFlags.oauth) {
oauthLoading = false;
@ -32,7 +30,7 @@
if (oauth.isCallback(window.location)) {
try {
await oauth.login(window.location);
dispatch('success');
await onSuccess();
return;
} catch (error) {
console.error('Error [login-form] [oauth.callback]', error);
@ -63,15 +61,15 @@
const serverConfig = await getServerConfig();
if (user.isAdmin && !serverConfig.isOnboarded) {
dispatch('onboarding');
await onOnboarding();
return;
}
if (!user.isAdmin && user.shouldChangePassword) {
dispatch('firstLogin');
await onFirstLogin();
return;
}
dispatch('success');
await onSuccess();
return;
} catch (error) {
errorMessage = (await getServerErrorMessage(error)) || 'Incorrect email or password';

View file

@ -26,9 +26,9 @@
</p>
<LoginForm
on:success={() => goto(AppRoute.PHOTOS, { invalidateAll: true })}
on:firstLogin={() => goto(AppRoute.AUTH_CHANGE_PASSWORD)}
on:onboarding={() => goto(AppRoute.AUTH_ONBOARDING)}
onSuccess={() => goto(AppRoute.PHOTOS, { invalidateAll: true })}
onFirstLogin={() => goto(AppRoute.AUTH_CHANGE_PASSWORD)}
onOnboarding={() => goto(AppRoute.AUTH_ONBOARDING)}
/>
</FullscreenContainer>
{/if}