mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-04 11:36:46 +00:00
feat: make home page URL configurable (#1215)
This commit is contained in:
@@ -505,5 +505,7 @@
|
||||
"scopes": "Scopes",
|
||||
"issuer_url": "Issuer URL",
|
||||
"smtp_field_required_when_other_provided": "Required when any SMTP setting is provided",
|
||||
"smtp_field_required_when_email_enabled": "Required when email notifications are enabled"
|
||||
"smtp_field_required_when_email_enabled": "Required when email notifications are enabled",
|
||||
"app_config_home_page": "Home Page",
|
||||
"app_config_home_page_description": "The page users are redirected to after signing in."
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="flex h-16 items-center">
|
||||
{#if !isAuthPage}
|
||||
<a
|
||||
href="/settings/account"
|
||||
href="/"
|
||||
class="flex items-center gap-3 transition-opacity hover:opacity-80"
|
||||
>
|
||||
<Logo class="size-8" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import userStore from '$lib/stores/user-store';
|
||||
import type { AllAppConfig, AppConfigRawResponse } from '$lib/types/application-configuration';
|
||||
import type { AllAppConfig, AppConfigRawResponse } from '$lib/types/application-configuration.type';
|
||||
import {
|
||||
cachedApplicationLogo,
|
||||
cachedBackgroundImage,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import AppConfigService from '$lib/services/app-config-service';
|
||||
import type { AppConfig } from '$lib/types/application-configuration';
|
||||
import type { AppConfig } from '$lib/types/application-configuration.type';
|
||||
import { applyAccentColor } from '$lib/utils/accent-color-util';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { CustomClaim } from './custom-claim.type';
|
||||
|
||||
export type AppConfig = {
|
||||
appName: string;
|
||||
homePageUrl: string;
|
||||
allowOwnAccountEdit: boolean;
|
||||
allowUserSignups: 'disabled' | 'withToken' | 'open';
|
||||
emailOneTimeAccessAsUnauthenticatedEnabled: boolean;
|
||||
@@ -1,5 +1,5 @@
|
||||
import VersionService from '$lib/services/version-service';
|
||||
import type { AppVersionInformation } from '$lib/types/application-configuration';
|
||||
import type { AppVersionInformation } from '$lib/types/application-configuration.type';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async () => {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
import appConfig from '$lib/stores/application-configuration-store';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(307, '/settings/account');
|
||||
throw redirect(307, get(appConfig).homePageUrl);
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import AppConfigService from '$lib/services/app-config-service';
|
||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration.type';
|
||||
import { axiosErrorToast } from '$lib/utils/error-util';
|
||||
import {
|
||||
LucideImage,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import AppConfigService from '$lib/services/app-config-service';
|
||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration.type';
|
||||
import { preventDefault } from '$lib/utils/event-util';
|
||||
import { createForm } from '$lib/utils/form-util';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import SwitchWithLabel from '$lib/components/form/switch-with-label.svelte';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import * as Field from '$lib/components/ui/field';
|
||||
import * as Select from '$lib/components/ui/select';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration.type';
|
||||
import { preventDefault } from '$lib/utils/event-util';
|
||||
import { createForm } from '$lib/utils/form-util';
|
||||
import { toast } from 'svelte-sonner';
|
||||
@@ -22,8 +23,14 @@
|
||||
|
||||
let isLoading = $state(false);
|
||||
|
||||
const homePageUrlOptions = [
|
||||
{ label: m.my_account(), value: '/settings/account' },
|
||||
{ label: m.my_apps(), value: '/settings/apps' }
|
||||
];
|
||||
|
||||
const updatedAppConfig = {
|
||||
appName: appConfig.appName,
|
||||
homePageUrl: appConfig.homePageUrl,
|
||||
sessionDuration: appConfig.sessionDuration,
|
||||
emailsVerified: appConfig.emailsVerified,
|
||||
allowOwnAccountEdit: appConfig.allowOwnAccountEdit,
|
||||
@@ -33,6 +40,7 @@
|
||||
|
||||
const formSchema = z.object({
|
||||
appName: z.string().min(2).max(30),
|
||||
homePageUrl: z.string(),
|
||||
sessionDuration: z.number().min(1).max(43200),
|
||||
emailsVerified: z.boolean(),
|
||||
allowOwnAccountEdit: z.boolean(),
|
||||
@@ -62,6 +70,32 @@
|
||||
description={m.the_duration_of_a_session_in_minutes_before_the_user_has_to_sign_in_again()}
|
||||
bind:input={$inputs.sessionDuration}
|
||||
/>
|
||||
<Field.Field>
|
||||
<Field.Label>{m.app_config_home_page()}</Field.Label>
|
||||
<Field.Description>
|
||||
{m.app_config_home_page_description()}
|
||||
</Field.Description>
|
||||
<Select.Root
|
||||
type="single"
|
||||
value={$inputs.homePageUrl.value}
|
||||
onValueChange={(v) => ($inputs.homePageUrl.value = v as string)}
|
||||
>
|
||||
<Select.Trigger
|
||||
class="w-full"
|
||||
aria-label={m.app_config_home_page()}
|
||||
>
|
||||
{homePageUrlOptions.find((option) => option.value === $inputs.homePageUrl.value)
|
||||
?.label ?? $inputs.homePageUrl.value}
|
||||
</Select.Trigger>
|
||||
<Select.Content>
|
||||
{#each homePageUrlOptions as option}
|
||||
<Select.Item value={option.value}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
{/each}
|
||||
</Select.Content>
|
||||
</Select.Root>
|
||||
</Field.Field>
|
||||
<SwitchWithLabel
|
||||
id="self-account-editing"
|
||||
label={m.enable_self_account_editing()}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import AppConfigService from '$lib/services/app-config-service';
|
||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration.type';
|
||||
import { axiosErrorToast } from '$lib/utils/error-util';
|
||||
import { preventDefault } from '$lib/utils/event-util';
|
||||
import { createForm } from '$lib/utils/form-util';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as Select from '$lib/components/ui/select';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration';
|
||||
import type { AllAppConfig } from '$lib/types/application-configuration.type';
|
||||
import { preventDefault } from '$lib/utils/event-util';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user