Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ const getDefaultPasswordStrengthPolicy = (): Models.PolicyPasswordStrength => ({
symbols: false
});

const getDefaultUserLimitPolicy = (): Models.PolicyUserLimit => ({
$id: ProjectPolicyId.Userlimit,
total: 0
});

export const load: PageLoad = async ({ depends, params }) => {
depends(Dependencies.PROJECT);

Expand Down Expand Up @@ -64,7 +69,9 @@ export const load: PageLoad = async ({ depends, params }) => {
ProjectPolicyId.Sessioninvalidation
] as Models.PolicySessionInvalidation,
sessionLimitPolicy: policiesById[ProjectPolicyId.Sessionlimit] as Models.PolicySessionLimit,
userLimitPolicy: policiesById[ProjectPolicyId.Userlimit] as Models.PolicyUserLimit,
userLimitPolicy:
(policiesById[ProjectPolicyId.Userlimit] as Models.PolicyUserLimit) ??
getDefaultUserLimitPolicy(),
denyAliasedEmailPolicy:
(policiesById[ProjectEmailPolicyId.DenyAliasedEmail] as EnabledPolicy) ??
getDefaultEnabledPolicy(ProjectEmailPolicyId.DenyAliasedEmail),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
let value = $state(policy.total !== 0 ? 'limited' : 'unlimited');
let newLimit = $state(policy.total !== 0 ? policy.total : 100);

$effect(() => {
value = policy.total !== 0 ? 'limited' : 'unlimited';
newLimit = policy.total !== 0 ? policy.total : 100;
});
Comment on lines +26 to +29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Policy Refresh Discards Edits

When any security policy form on this page saves, it invalidates the project data and refreshes data.userLimitPolicy. This effect then copies the refreshed policy back into value and newLimit, so a user who is editing the user limit can lose their unsaved radio or number input after an unrelated policy update.

Context Used: AGENTS.md (source)

Knowledge Base Used: Messaging, Storage, and Auth in the project console

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/routes/(console)/project-[region]-[project]/auth/security/updateUsersLimit.svelte
Line: 26-29

Comment:
**Policy Refresh Discards Edits**

When any security policy form on this page saves, it invalidates the project data and refreshes `data.userLimitPolicy`. This effect then copies the refreshed policy back into `value` and `newLimit`, so a user who is editing the user limit can lose their unsaved radio or number input after an unrelated policy update.

**Context Used:** AGENTS.md ([source](https://app.greptile.com/appwrite/github/appwrite/console/-/custom-context?memory=f4227d43-a98a-4882-876a-cad1bc006878))

**Knowledge Base Used:** [Messaging, Storage, and Auth in the project console](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/console/-/docs/messaging-storage-authusers.md)

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex


const isLimited = $derived(value === 'limited');
const btnDisabled = $derived.by(() => {
return (!isLimited && policy.total === 0) || (isLimited && policy.total === newLimit);
Expand Down