diff --git a/src/lib/api/base.ts b/src/lib/api/base.ts index fe47aa0f..87c90a9f 100644 --- a/src/lib/api/base.ts +++ b/src/lib/api/base.ts @@ -1,5 +1,5 @@ -import { env } from '$env/dynamic/public'; -import * as types from './types'; +import { env } from '$env/dynamic/public' +import * as types from './types' export type ClientType = | { name: 'lemmy'; baseUrl: '/api/v3' } @@ -19,6 +19,13 @@ export const DEFAULT_CLIENT_TYPE: ClientType = export abstract class BaseClient { abstract type: ClientType + static constants: { + password: { + minLength: number + maxLength: number + } + } + abstract getSite(): Promise abstract editSite(form: types.EditSite): Promise abstract generateTotpSecret(): Promise diff --git a/src/lib/api/lemmy/adapter.ts b/src/lib/api/lemmy/adapter.ts index c3a25c55..4139f806 100644 --- a/src/lib/api/lemmy/adapter.ts +++ b/src/lib/api/lemmy/adapter.ts @@ -5,6 +5,8 @@ import { fromGetPosts, toListingType } from './rewrite' export class LemmyClient implements BaseClient { type: ClientType = { name: 'lemmy', baseUrl: '/api/v3' } + static constants = { password: { minLength: 8, maxLength: 60 } } + #client: LemmyHttp constructor( diff --git a/src/lib/api/piefed/adapter.ts b/src/lib/api/piefed/adapter.ts index 4bf9b4f9..2efea6d2 100644 --- a/src/lib/api/piefed/adapter.ts +++ b/src/lib/api/piefed/adapter.ts @@ -38,6 +38,8 @@ import type { paths } from './schema' export class PiefedClient implements BaseClient { type: ClientType = { name: 'piefed', baseUrl: '/api/alpha' } + static constants = { password: { minLength: 6, maxLength: 128 } } + #client: ReturnType> constructor( diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index 9030fddb..e7f7ca96 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -3,6 +3,8 @@ import { page } from '$app/state' import { type ClientType, DEFAULT_CLIENT_TYPE } from '$lib/api/base' import { client } from '$lib/api/client.svelte' + import { LemmyClient } from '$lib/api/lemmy/adapter' + import { PiefedClient } from '$lib/api/piefed/adapter' import { profile } from '$lib/app/auth.svelte' import { errorMessage } from '$lib/app/error' import { t } from '$lib/app/i18n' @@ -171,14 +173,18 @@ {/if} -
+