Skip to content

Commit 8d75905

Browse files
committed
preserve password limit
1 parent 2d2b102 commit 8d75905

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<script lang="ts">
22
import { Container } from '$lib/layout';
3-
import { page } from '$app/state';
3+
import type { PageProps } from './$types';
44
import UpdateMockNumbers from './updateMockNumbers.svelte';
55
import UpdateMembershipPrivacy from './updateMembershipPrivacy.svelte';
66
import UpdateUsersLimit from './updateUsersLimit.svelte';
77
import UpdateSessionLength from './updateSessionLength.svelte';
88
import UpdateSessionsLimit from './updateSessionsLimit.svelte';
99
import PasswordPolicies from './passwordPolicies.svelte';
1010
import SessionSecurity from './sessionSecurity.svelte';
11+
12+
let { data }: PageProps = $props();
1113
</script>
1214

1315
<Container>
1416
<UpdateUsersLimit />
1517
<UpdateSessionLength />
1618
<UpdateSessionsLimit />
17-
<PasswordPolicies project={page.data.project} />
18-
<SessionSecurity project={page.data.project} />
19+
<PasswordPolicies project={data.project} />
20+
<SessionSecurity project={data.project} />
1921
<UpdateMockNumbers />
2022
<UpdateMembershipPrivacy />
2123
</Container>

src/routes/(console)/project-[region]-[project]/auth/security/passwordPolicies.svelte

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,29 @@
1616
let passwordHistoryEnabled = $state(false);
1717
let passwordDictionary = $state(false);
1818
let authPersonalDataCheck = $state(false);
19+
let lastValidLimit = $state(5);
1920
2021
let maxPasswordInputField: InputNumber | null = null;
2122
2223
// Initialize and sync state when project updates
2324
$effect(() => {
2425
const historyValue = project?.authPasswordHistory;
25-
passwordHistory = historyValue < 1 ? 5 : historyValue;
26+
if (historyValue && historyValue > 0) {
27+
passwordHistory = historyValue;
28+
lastValidLimit = historyValue;
29+
}
2630
passwordHistoryEnabled = (historyValue ?? 0) !== 0;
2731
passwordDictionary = project?.authPasswordDictionary ?? false;
2832
authPersonalDataCheck = project?.authPersonalDataCheck ?? false;
2933
});
3034
35+
// restore last valid limit when enabling
36+
$effect(() => {
37+
if (passwordHistoryEnabled && passwordHistory < 1) {
38+
passwordHistory = lastValidLimit;
39+
}
40+
});
41+
3142
$effect(() => {
3243
if (passwordHistoryEnabled) {
3344
tick().then(() => {

0 commit comments

Comments
 (0)