mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +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 { oauth } from '$lib/utils';
|
||||||
import { getServerErrorMessage, handleError } from '$lib/utils/handle-error';
|
import { getServerErrorMessage, handleError } from '$lib/utils/handle-error';
|
||||||
import { getServerConfig, login } from '@immich/sdk';
|
import { getServerConfig, login } from '@immich/sdk';
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
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 errorMessage: string;
|
||||||
let email = '';
|
let email = '';
|
||||||
let password = '';
|
let password = '';
|
||||||
|
@ -17,12 +21,6 @@
|
||||||
let loading = false;
|
let loading = false;
|
||||||
let oauthLoading = true;
|
let oauthLoading = true;
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{
|
|
||||||
success: void;
|
|
||||||
firstLogin: void;
|
|
||||||
onboarding: void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (!$featureFlags.oauth) {
|
if (!$featureFlags.oauth) {
|
||||||
oauthLoading = false;
|
oauthLoading = false;
|
||||||
|
@ -32,7 +30,7 @@
|
||||||
if (oauth.isCallback(window.location)) {
|
if (oauth.isCallback(window.location)) {
|
||||||
try {
|
try {
|
||||||
await oauth.login(window.location);
|
await oauth.login(window.location);
|
||||||
dispatch('success');
|
await onSuccess();
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error [login-form] [oauth.callback]', error);
|
console.error('Error [login-form] [oauth.callback]', error);
|
||||||
|
@ -63,15 +61,15 @@
|
||||||
const serverConfig = await getServerConfig();
|
const serverConfig = await getServerConfig();
|
||||||
|
|
||||||
if (user.isAdmin && !serverConfig.isOnboarded) {
|
if (user.isAdmin && !serverConfig.isOnboarded) {
|
||||||
dispatch('onboarding');
|
await onOnboarding();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.isAdmin && user.shouldChangePassword) {
|
if (!user.isAdmin && user.shouldChangePassword) {
|
||||||
dispatch('firstLogin');
|
await onFirstLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch('success');
|
await onSuccess();
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errorMessage = (await getServerErrorMessage(error)) || 'Incorrect email or password';
|
errorMessage = (await getServerErrorMessage(error)) || 'Incorrect email or password';
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<LoginForm
|
<LoginForm
|
||||||
on:success={() => goto(AppRoute.PHOTOS, { invalidateAll: true })}
|
onSuccess={() => goto(AppRoute.PHOTOS, { invalidateAll: true })}
|
||||||
on:firstLogin={() => goto(AppRoute.AUTH_CHANGE_PASSWORD)}
|
onFirstLogin={() => goto(AppRoute.AUTH_CHANGE_PASSWORD)}
|
||||||
on:onboarding={() => goto(AppRoute.AUTH_ONBOARDING)}
|
onOnboarding={() => goto(AppRoute.AUTH_ONBOARDING)}
|
||||||
/>
|
/>
|
||||||
</FullscreenContainer>
|
</FullscreenContainer>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue