chore: remove claim page (#169)

This commit is contained in:
Jason Rasmussen
2025-08-08 08:27:13 -04:00
committed by GitHub
parent d21f771e63
commit 150c86d169
5 changed files with 0 additions and 151 deletions
@@ -1,96 +0,0 @@
<script lang="ts">
import { goto } from '$app/navigation';
import LicenseKey from '$lib/components/LicenseKey.svelte';
import DefaultPageLayout from '$lib/layouts/DefaultPageLayout.svelte';
import { getAuthorizeUrl } from '$lib/utils/oauth';
import { Alert, Button, Heading, Link, Stack, Text } from '@immich/ui';
import { mdiGithub } from '@mdi/js';
import type { PageData } from './$types';
interface Props {
data: PageData;
}
let { data }: Props = $props();
const s = (n: number) => (n === 1 ? '' : 's');
let errorMessage = $state(data.error);
const response = data.response;
if (response) {
goto('/claim', { replaceState: true });
}
const handleLogin = async () => {
try {
const { error, url } = await getAuthorizeUrl();
if (url) {
window.location.href = url;
} else {
errorMessage = error;
}
} catch (error: Error | unknown) {
errorMessage = error instanceof Error ? error?.message : String(error);
}
};
</script>
<svelte:head>
<title>Immich - Claim</title>
</svelte:head>
<DefaultPageLayout>
<Stack gap={8}>
<section>
<Stack>
<Heading size="giant" color="primary" class="uppercase" tag="h1">Claim your key</Heading>
<Text size="large">
If you previously supported Immich by sponsoring the project on GitHub, you are entitled to a free product
key. Login below with your GitHub account to claim your key.
</Text>
</Stack>
</section>
{#if response}
<div class="flex flex-col sm:flex-row gap-4 sm:items-center">
<img src={response.imageUrl} class="h-16 w-16" alt="GitHub profile" />
<div>
<Text size="giant">Welcome back <strong>{response.username}</strong>!</Text>
{#if response.licenses.length > 0}
<Text size="large">
We found <strong>{response.licenses.length}</strong> product key{s(response.licenses.length)}.
</Text>
{/if}
</div>
</div>
{#if response.licenses.length === 0}
<section>
<Alert color="secondary" title="No product keys">
<Text>
Unfortunately, we did not find any product keys associated with your account. If you think this is a
mistake, please send an email to <Link href="mailto:claim@immich.app">claim@immich.app</Link>.
</Text>
</Alert>
</section>
{/if}
<Stack gap={4}>
{#each response.licenses as license (license.licenseKey)}
<LicenseKey productKey={license.licenseKey} />
{/each}
</Stack>
{:else}
<section>
<Stack align="start" gap={4}>
<Button leadingIcon={mdiGithub} onclick={handleLogin} color="secondary" variant="outline">
<Text>Login with GitHub</Text>
</Button>
{#if errorMessage}
<Alert title={errorMessage} color="danger" />
{/if}
</Stack>
</section>
{/if}
</Stack>
</DefaultPageLayout>
@@ -1,9 +0,0 @@
import { callback } from '$lib/utils/oauth';
import type { PageLoad } from './$types';
export const load = (async ({ fetch, url, params }) => {
if (params.id === 'callback') {
const { response, error } = await callback(fetch, url.href);
return { response, error };
}
}) satisfies PageLoad;
-2
View File
@@ -1,5 +1,3 @@
IMMICH_APP=buy.immich.app
PUBLIC_IMMICH_PAY_HOST=https://futopay-test.azurewebsites.net
# PUBLIC_IMMICH_API_HOST=http://localhost:8080
# PUBLIC_IMMICH_API_HOST=https://api.immich.app
# PUBLIC_IMMICH_SPEC_URL=http://localhost:3000/api/spec.json
-43
View File
@@ -1,43 +0,0 @@
import { PUBLIC_IMMICH_API_HOST } from '$env/static/public';
import type { Fetch } from '$lib';
import type { ImmichLicense } from '$lib/utils/license';
export type License = { type: ImmichLicense; licenseKey: string; activationKey: string };
export type ClaimSuccessResponseDto = {
username: string;
imageUrl: string;
licenses: License[];
};
export type ClaimErrorResponseDto = {
error: string;
};
export const getAuthorizeUrl = async () => {
const response = await fetch(new URL('/oauth/authorize', PUBLIC_IMMICH_API_HOST).href, {
method: 'POST',
body: JSON.stringify({ redirectUri: window.location.origin + '/claim/callback' }),
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
return { error: 'Something went wrong' };
}
const { url } = await response.json();
return { url };
};
export const callback = async (fetch: Fetch, url: string) => {
const response = await fetch(new URL('/oauth/callback', PUBLIC_IMMICH_API_HOST).href, {
method: 'POST',
body: JSON.stringify({ url }),
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
return { error: 'Unable to login with GitHub' };
}
return { response: (await response.json()) as ClaimSuccessResponseDto };
};
-1
View File
@@ -5,7 +5,6 @@ import dotenv from 'dotenv';
dotenv.config();
process.env.PUBLIC_IMMICH_PAY_HOST = process.env.PUBLIC_IMMICH_PAY_HOST || 'https://pay.futo.org';
process.env.PUBLIC_IMMICH_API_HOST = process.env.PUBLIC_IMMICH_API_HOST || 'https://api.immich.app';
process.env.PUBLIC_IMMICH_SPEC_URL = process.env.PUBLIC_IMMICH_SPEC_URL || 'https://static.immich.cloud/docs/spec.json';
const app = process.env.IMMICH_APP || 'my.immich.app';