From 1fa67227eda44ec24b076fd66be74475e8059941 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Wed, 31 Dec 2025 01:20:40 +0530 Subject: [PATCH 1/8] feat: New Group security cards --- .../auth/security/+page.svelte | 18 +-- .../auth/security/passwordPolicies.svelte | 150 ++++++++++++++++++ .../auth/security/sessionSecurity.svelte | 94 +++++++++++ .../security/updatePasswordDictionary.svelte | 61 ------- .../security/updatePasswordHistory.svelte | 80 ---------- .../security/updatePersonalDataCheck.svelte | 56 ------- .../auth/security/updateSessionAlerts.svelte | 54 ------- .../security/updateSessionInvalidation.svelte | 56 ------- 8 files changed, 250 insertions(+), 319 deletions(-) create mode 100644 src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte create mode 100644 src/routes/(console)/project-[region]-[project]/auth/security/sessionSecurity.svelte delete mode 100644 src/routes/(console)/project-[region]-[project]/auth/security/updatePasswordDictionary.svelte delete mode 100644 src/routes/(console)/project-[region]-[project]/auth/security/updatePasswordHistory.svelte delete mode 100644 src/routes/(console)/project-[region]-[project]/auth/security/updatePersonalDataCheck.svelte delete mode 100644 src/routes/(console)/project-[region]-[project]/auth/security/updateSessionAlerts.svelte delete mode 100644 src/routes/(console)/project-[region]-[project]/auth/security/updateSessionInvalidation.svelte diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/+page.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/+page.svelte index 48718cba38..c7c34b5c1b 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/+page.svelte @@ -1,26 +1,20 @@ - - - - - + + diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte new file mode 100644 index 0000000000..ddc4be0878 --- /dev/null +++ b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte @@ -0,0 +1,150 @@ + + +
+ + Password policies + + + + + + Enabling this option prevents users from reusing recent passwords by + comparing the new password with their password history. + + {#if passwordHistoryEnabled} + + {/if} + + + + + + + + Enabling this option prevent users from setting insecure passwords by + comparing the user's password with the 10k most commonly used passwords. + + + + + + + + Do not allow passwords that contain any part of the user's personal data. + This includes the user's name, email, or phone. + + + + + + + + + +
diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/sessionSecurity.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/sessionSecurity.svelte new file mode 100644 index 0000000000..e2b4be9e02 --- /dev/null +++ b/src/routes/(console)/project-[region]-[project]/auth/security/sessionSecurity.svelte @@ -0,0 +1,94 @@ + + +
+ + Session security + + + + + Enabling this option will send an email to the users when a new session is + created. + + + + + + + + Enabling this option will clear all existing sessions when the user changes + their password. + + + + + + + + + +
diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/updatePasswordDictionary.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/updatePasswordDictionary.svelte deleted file mode 100644 index 0e921ab044..0000000000 --- a/src/routes/(console)/project-[region]-[project]/auth/security/updatePasswordDictionary.svelte +++ /dev/null @@ -1,61 +0,0 @@ - - -
- - Password dictionary - - - - Enabling this option prevent users from setting insecure passwords by comparing the - user's password with the 10k most commonly used passwords. - - - - - - - -
diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/updatePasswordHistory.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/updatePasswordHistory.svelte deleted file mode 100644 index 0b42184874..0000000000 --- a/src/routes/(console)/project-[region]-[project]/auth/security/updatePasswordHistory.svelte +++ /dev/null @@ -1,80 +0,0 @@ - - -
- - Password history - Set the maximum number of passwords saved per user. - - - - Enabling this option prevents users from reusing recent passwords by comparing the - new password with their password history. - - - - - - - - -
diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/updatePersonalDataCheck.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/updatePersonalDataCheck.svelte deleted file mode 100644 index 71f87c24d3..0000000000 --- a/src/routes/(console)/project-[region]-[project]/auth/security/updatePersonalDataCheck.svelte +++ /dev/null @@ -1,56 +0,0 @@ - - -
- - Personal data - - - - Do not allow passwords that contain any part of the user's personal data. This - includes the user's name, email, or phone. - - - - - - -
diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/updateSessionAlerts.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/updateSessionAlerts.svelte deleted file mode 100644 index ba8af9ec9d..0000000000 --- a/src/routes/(console)/project-[region]-[project]/auth/security/updateSessionAlerts.svelte +++ /dev/null @@ -1,54 +0,0 @@ - - -
- - Session alerts - - - - Enabling this option will send an email to the users when a new session is created. - - - - - - -
diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/updateSessionInvalidation.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/updateSessionInvalidation.svelte deleted file mode 100644 index c2c449e3eb..0000000000 --- a/src/routes/(console)/project-[region]-[project]/auth/security/updateSessionInvalidation.svelte +++ /dev/null @@ -1,56 +0,0 @@ - - -
- - Invalidate sessions - - - - Enabling this option will clear all existing sessions when the user changes their - password. - - - - - - - -
From 44c693befdc39bfda382c1366cd06c88971a6ab9 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Wed, 31 Dec 2025 01:26:09 +0530 Subject: [PATCH 2/8] Update src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../auth/security/passwordPolicies.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte index ddc4be0878..f39b5203d4 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte @@ -117,7 +117,7 @@ label="Password dictionary"> - Enabling this option prevent users from setting insecure passwords by + Enabling this option prevents users from setting insecure passwords by comparing the user's password with the Date: Wed, 31 Dec 2025 10:37:18 +0530 Subject: [PATCH 3/8] no store import in security page --- .../auth/security/+page.svelte | 5 ++-- .../auth/security/passwordPolicies.svelte | 25 ++++++++++--------- .../auth/security/sessionSecurity.svelte | 5 ++-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/+page.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/+page.svelte index c7c34b5c1b..6c0ce43597 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/+page.svelte @@ -1,5 +1,6 @@ - - + + diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte index d57c738429..46547cecb9 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte @@ -16,18 +16,29 @@ let passwordHistoryEnabled = $state(false); let passwordDictionary = $state(false); let authPersonalDataCheck = $state(false); + let lastValidLimit = $state(5); let maxPasswordInputField: InputNumber | null = null; // Initialize and sync state when project updates $effect(() => { const historyValue = project?.authPasswordHistory; - passwordHistory = historyValue < 1 ? 5 : historyValue; + if (historyValue && historyValue > 0) { + passwordHistory = historyValue; + lastValidLimit = historyValue; + } passwordHistoryEnabled = (historyValue ?? 0) !== 0; passwordDictionary = project?.authPasswordDictionary ?? false; authPersonalDataCheck = project?.authPersonalDataCheck ?? false; }); + // restore last valid limit when enabling + $effect(() => { + if (passwordHistoryEnabled && passwordHistory < 1) { + passwordHistory = lastValidLimit; + } + }); + $effect(() => { if (passwordHistoryEnabled) { tick().then(() => { From 7a595b1197add536f835df75c2fa0505a84d8e7e Mon Sep 17 00:00:00 2001 From: Darshan Date: Fri, 2 Jan 2026 14:21:37 +0530 Subject: [PATCH 7/8] update: improvements. --- .../auth/security/passwordPolicies.svelte | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte index 46547cecb9..004e772eec 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte @@ -8,65 +8,63 @@ import { sdk } from '$lib/stores/sdk'; import { Typography, Link, Layout } from '@appwrite.io/pink-svelte'; import type { Models } from '@appwrite.io/console'; - import { tick } from 'svelte'; + import { onMount } from 'svelte'; - let { project }: { project: Models.Project } = $props(); + let { + project + }: { + project: Models.Project; + } = $props(); + let lastValidLimit = $state(5); let passwordHistory = $state(5); - let passwordHistoryEnabled = $state(false); let passwordDictionary = $state(false); + let passwordHistoryEnabled = $state(false); let authPersonalDataCheck = $state(false); - let lastValidLimit = $state(5); - - let maxPasswordInputField: InputNumber | null = null; - // Initialize and sync state when project updates - $effect(() => { - const historyValue = project?.authPasswordHistory; + onMount(() => { + // update initial states here in onMount. + const historyValue = project.authPasswordHistory; if (historyValue && historyValue > 0) { passwordHistory = historyValue; lastValidLimit = historyValue; } + passwordHistoryEnabled = (historyValue ?? 0) !== 0; - passwordDictionary = project?.authPasswordDictionary ?? false; - authPersonalDataCheck = project?.authPersonalDataCheck ?? false; + passwordDictionary = project.authPasswordDictionary ?? false; + authPersonalDataCheck = project.authPersonalDataCheck ?? false; }); - // restore last valid limit when enabling $effect(() => { + // restore last valid limit when enabling if (passwordHistoryEnabled && passwordHistory < 1) { passwordHistory = lastValidLimit; } }); - $effect(() => { - if (passwordHistoryEnabled) { - tick().then(() => { - if (maxPasswordInputField) { - maxPasswordInputField.addInputFocus(); - } - }); - } - }); + const hasChanges = $derived.by(() => { + const dictChanged = passwordDictionary !== project.authPasswordDictionary; + const dataCheckChanged = authPersonalDataCheck !== project.authPersonalDataCheck; + const historyChanged = passwordHistoryEnabled !== (project.authPasswordHistory !== 0); - const hasChanges = $derived( - passwordHistoryEnabled !== ((project?.authPasswordHistory ?? 0) !== 0) || - (passwordHistoryEnabled && passwordHistory !== (project?.authPasswordHistory ?? 0)) || - passwordDictionary !== (project?.authPasswordDictionary ?? false) || - authPersonalDataCheck !== (project?.authPersonalDataCheck ?? false) - ); + return historyChanged || dictChanged || dataCheckChanged; + }); async function updatePasswordPolicies() { try { - await sdk.forConsole.projects.updateAuthPasswordHistory({ + const projectSdk = sdk.forConsole.projects; + + await projectSdk.updateAuthPasswordHistory({ projectId: project.$id, limit: passwordHistoryEnabled ? passwordHistory : 0 }); - await sdk.forConsole.projects.updateAuthPasswordDictionary({ + + await projectSdk.updateAuthPasswordDictionary({ projectId: project.$id, enabled: passwordDictionary }); - await sdk.forConsole.projects.updatePersonalDataCheck({ + + await projectSdk.updatePersonalDataCheck({ projectId: project.$id, enabled: authPersonalDataCheck }); @@ -108,10 +106,10 @@ required max={20} min={1} - id="password-history" + autofocus label="Limit" + id="password-history" bind:value={passwordHistory} - bind:this={maxPasswordInputField} helper="Maximum 20 passwords." /> {/if} From 0c65c0d79060215e899a4d656bd035a651b51769 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Fri, 2 Jan 2026 15:02:07 +0530 Subject: [PATCH 8/8] added limitchanged --- .../auth/security/passwordPolicies.svelte | 14 +++++++++----- .../auth/security/sessionSecurity.svelte | 14 ++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte index 004e772eec..22898b060c 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte @@ -43,11 +43,15 @@ }); const hasChanges = $derived.by(() => { - const dictChanged = passwordDictionary !== project.authPasswordDictionary; - const dataCheckChanged = authPersonalDataCheck !== project.authPersonalDataCheck; - const historyChanged = passwordHistoryEnabled !== (project.authPasswordHistory !== 0); - - return historyChanged || dictChanged || dataCheckChanged; + const dictChanged = passwordDictionary !== (project.authPasswordDictionary ?? false); + const dataCheckChanged = authPersonalDataCheck !== (project.authPersonalDataCheck ?? false); + const historyChanged = + passwordHistoryEnabled !== ((project.authPasswordHistory ?? 0) !== 0); + const limitChanged = + passwordHistoryEnabled && + Number(passwordHistory) !== (project.authPasswordHistory ?? 0); + + return historyChanged || dictChanged || dataCheckChanged || limitChanged; }); async function updatePasswordPolicies() { diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/sessionSecurity.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/sessionSecurity.svelte index f64fee94ed..6babbbecc6 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/sessionSecurity.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/sessionSecurity.svelte @@ -8,22 +8,24 @@ import { sdk } from '$lib/stores/sdk'; import { Typography } from '@appwrite.io/pink-svelte'; import type { Models } from '@appwrite.io/console'; + import { onMount } from 'svelte'; let { project }: { project: Models.Project } = $props(); let authSessionAlerts = $state(false); let sessionInvalidation = $state(false); - // Initialize state from project - $effect(() => { + onMount(() => { authSessionAlerts = project?.authSessionAlerts ?? false; sessionInvalidation = project?.authInvalidateSessions ?? false; }); - const hasChanges = $derived( - authSessionAlerts !== (project?.authSessionAlerts ?? false) || - sessionInvalidation !== (project?.authInvalidateSessions ?? false) - ); + const hasChanges = $derived.by(() => { + const alertsChanged = authSessionAlerts !== (project?.authSessionAlerts ?? false); + const invalidationChanged = + sessionInvalidation !== (project?.authInvalidateSessions ?? false); + return alertsChanged || invalidationChanged; + }); async function updateSessionSecurity() { try {