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:
parent
857ec0451d
commit
3480fe5326
2 changed files with 12 additions and 14 deletions
|
@ -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';
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue