mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-04 15:04:43 +00:00
fix: disable sign up options in UI if UI_CONFIG_DISABLED
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import SwitchWithLabel from '$lib/components/form/switch-with-label.svelte';
|
|
||||||
import FormInput from '$lib/components/form/form-input.svelte';
|
import FormInput from '$lib/components/form/form-input.svelte';
|
||||||
|
import SwitchWithLabel from '$lib/components/form/switch-with-label.svelte';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import { m } from '$lib/paraglide/messages';
|
import { m } from '$lib/paraglide/messages';
|
||||||
import AppConfigService from '$lib/services/app-config-service';
|
import AppConfigService from '$lib/services/app-config-service';
|
||||||
@@ -25,28 +25,6 @@
|
|||||||
let ldapEnabled = $state(appConfig.ldapEnabled);
|
let ldapEnabled = $state(appConfig.ldapEnabled);
|
||||||
let ldapSyncing = $state(false);
|
let ldapSyncing = $state(false);
|
||||||
|
|
||||||
const updatedAppConfig = {
|
|
||||||
ldapEnabled: appConfig.ldapEnabled,
|
|
||||||
ldapUrl: appConfig.ldapUrl,
|
|
||||||
ldapBindDn: appConfig.ldapBindDn,
|
|
||||||
ldapBindPassword: appConfig.ldapBindPassword,
|
|
||||||
ldapBase: appConfig.ldapBase,
|
|
||||||
ldapUserSearchFilter: appConfig.ldapUserSearchFilter,
|
|
||||||
ldapUserGroupSearchFilter: appConfig.ldapUserGroupSearchFilter,
|
|
||||||
ldapSkipCertVerify: appConfig.ldapSkipCertVerify,
|
|
||||||
ldapAttributeUserUniqueIdentifier: appConfig.ldapAttributeUserUniqueIdentifier,
|
|
||||||
ldapAttributeUserUsername: appConfig.ldapAttributeUserUsername,
|
|
||||||
ldapAttributeUserEmail: appConfig.ldapAttributeUserEmail,
|
|
||||||
ldapAttributeUserFirstName: appConfig.ldapAttributeUserFirstName,
|
|
||||||
ldapAttributeUserLastName: appConfig.ldapAttributeUserLastName,
|
|
||||||
ldapAttributeUserProfilePicture: appConfig.ldapAttributeUserProfilePicture,
|
|
||||||
ldapAttributeGroupMember: appConfig.ldapAttributeGroupMember,
|
|
||||||
ldapAttributeGroupUniqueIdentifier: appConfig.ldapAttributeGroupUniqueIdentifier,
|
|
||||||
ldapAttributeGroupName: appConfig.ldapAttributeGroupName,
|
|
||||||
ldapAttributeAdminGroup: appConfig.ldapAttributeAdminGroup,
|
|
||||||
ldapSoftDeleteUsers: appConfig.ldapSoftDeleteUsers || true
|
|
||||||
};
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
ldapUrl: z.url(),
|
ldapUrl: z.url(),
|
||||||
ldapBindDn: z.string().min(1),
|
ldapBindDn: z.string().min(1),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import * as Select from '$lib/components/ui/select';
|
import * as Select from '$lib/components/ui/select';
|
||||||
import { m } from '$lib/paraglide/messages';
|
import { m } from '$lib/paraglide/messages';
|
||||||
import UserGroupService from '$lib/services/user-group-service';
|
import UserGroupService from '$lib/services/user-group-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';
|
||||||
import { debounced } from '$lib/utils/debounce-util';
|
import { debounced } from '$lib/utils/debounce-util';
|
||||||
import { preventDefault } from '$lib/utils/event-util';
|
import { preventDefault } from '$lib/utils/event-util';
|
||||||
@@ -95,82 +96,84 @@
|
|||||||
onMount(() => loadUserGroups());
|
onMount(() => loadUserGroups());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form class="space-y-6" onsubmit={preventDefault(onSubmit)}>
|
<form onsubmit={preventDefault(onSubmit)}>
|
||||||
<div class="grid gap-2">
|
<fieldset class="flex flex-col gap-5" disabled={$appConfigStore.uiConfigDisabled}>
|
||||||
<div>
|
<div class="grid gap-2">
|
||||||
<Label class="mb-0" for="enable-user-signup">{m.enable_user_signups()}</Label>
|
<div>
|
||||||
<p class="text-muted-foreground text-[0.8rem]">
|
<Label class="mb-0" for="enable-user-signup">{m.enable_user_signups()}</Label>
|
||||||
{m.enable_user_signups_description()}
|
<p class="text-muted-foreground text-[0.8rem]">
|
||||||
</p>
|
{m.enable_user_signups_description()}
|
||||||
</div>
|
</p>
|
||||||
<Select.Root
|
</div>
|
||||||
type="single"
|
<Select.Root
|
||||||
value={allowUserSignups}
|
type="single"
|
||||||
onValueChange={(v) => (allowUserSignups = v as typeof allowUserSignups)}
|
value={allowUserSignups}
|
||||||
>
|
onValueChange={(v) => (allowUserSignups = v as typeof allowUserSignups)}
|
||||||
<Select.Trigger
|
|
||||||
id="enable-user-signup"
|
|
||||||
class="w-full"
|
|
||||||
aria-label={m.enable_user_signups()}
|
|
||||||
placeholder={m.enable_user_signups()}
|
|
||||||
>
|
>
|
||||||
{signupOptions[allowUserSignups]?.label}
|
<Select.Trigger
|
||||||
</Select.Trigger>
|
id="enable-user-signup"
|
||||||
<Select.Content>
|
class="w-full"
|
||||||
<Select.Item value="disabled">
|
aria-label={m.enable_user_signups()}
|
||||||
<div class="flex flex-col items-start gap-1">
|
placeholder={m.enable_user_signups()}
|
||||||
<span class="font-medium">{signupOptions.disabled.label}</span>
|
>
|
||||||
<span class="text-muted-foreground text-xs">
|
{signupOptions[allowUserSignups]?.label}
|
||||||
{signupOptions.disabled.description}
|
</Select.Trigger>
|
||||||
</span>
|
<Select.Content>
|
||||||
</div>
|
<Select.Item value="disabled">
|
||||||
</Select.Item>
|
<div class="flex flex-col items-start gap-1">
|
||||||
<Select.Item value="withToken">
|
<span class="font-medium">{signupOptions.disabled.label}</span>
|
||||||
<div class="flex flex-col items-start gap-1">
|
<span class="text-muted-foreground text-xs">
|
||||||
<span class="font-medium">{signupOptions.withToken.label}</span>
|
{signupOptions.disabled.description}
|
||||||
<span class="text-muted-foreground text-xs">
|
</span>
|
||||||
{signupOptions.withToken.description}
|
</div>
|
||||||
</span>
|
</Select.Item>
|
||||||
</div>
|
<Select.Item value="withToken">
|
||||||
</Select.Item>
|
<div class="flex flex-col items-start gap-1">
|
||||||
<Select.Item value="open">
|
<span class="font-medium">{signupOptions.withToken.label}</span>
|
||||||
<div class="flex flex-col items-start gap-1">
|
<span class="text-muted-foreground text-xs">
|
||||||
<span class="font-medium">{signupOptions.open.label}</span>
|
{signupOptions.withToken.description}
|
||||||
<span class="text-muted-foreground text-xs">
|
</span>
|
||||||
{signupOptions.open.description}
|
</div>
|
||||||
</span>
|
</Select.Item>
|
||||||
</div>
|
<Select.Item value="open">
|
||||||
</Select.Item>
|
<div class="flex flex-col items-start gap-1">
|
||||||
</Select.Content>
|
<span class="font-medium">{signupOptions.open.label}</span>
|
||||||
</Select.Root>
|
<span class="text-muted-foreground text-xs">
|
||||||
</div>
|
{signupOptions.open.description}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</Select.Item>
|
||||||
|
</Select.Content>
|
||||||
|
</Select.Root>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label for="default-groups" class="mb-0">{m.user_groups()}</Label>
|
<Label for="default-groups" class="mb-0">{m.user_groups()}</Label>
|
||||||
<p class="text-muted-foreground mt-1 mb-2 text-xs">
|
<p class="text-muted-foreground mt-1 mb-2 text-xs">
|
||||||
{m.user_creation_groups_description()}
|
{m.user_creation_groups_description()}
|
||||||
</p>
|
</p>
|
||||||
<SearchableMultiSelect
|
<SearchableMultiSelect
|
||||||
id="default-groups"
|
id="default-groups"
|
||||||
items={userGroups}
|
items={userGroups}
|
||||||
oninput={(e) => onUserGroupSearch(e.currentTarget.value)}
|
oninput={(e) => onUserGroupSearch(e.currentTarget.value)}
|
||||||
selectedItems={selectedGroups.map((g) => g.value)}
|
selectedItems={selectedGroups.map((g) => g.value)}
|
||||||
onSelect={(selected) => {
|
onSelect={(selected) => {
|
||||||
selectedGroups = userGroups.filter((g) => selected.includes(g.value));
|
selectedGroups = userGroups.filter((g) => selected.includes(g.value));
|
||||||
}}
|
}}
|
||||||
isLoading={isUserSearchLoading}
|
isLoading={isUserSearchLoading}
|
||||||
disableInternalSearch
|
disableInternalSearch
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Label class="mb-0">{m.custom_claims()}</Label>
|
<Label class="mb-0">{m.custom_claims()}</Label>
|
||||||
<p class="text-muted-foreground mt-1 mb-2 text-xs">
|
<p class="text-muted-foreground mt-1 mb-2 text-xs">
|
||||||
{m.user_creation_claims_description()}
|
{m.user_creation_claims_description()}
|
||||||
</p>
|
</p>
|
||||||
<CustomClaimsInput bind:customClaims />
|
<CustomClaimsInput bind:customClaims />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-end pt-2">
|
<div class="flex justify-end pt-2">
|
||||||
<Button {isLoading} type="submit">{m.save()}</Button>
|
<Button {isLoading} type="submit">{m.save()}</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user