fix: gate MFA factors policy behind the project write scope

Matches the project settings cards, which disable their controls on
!$canWriteProjects rather than letting a read-only member submit a
request the API rejects.

Also fills in labels, installationScopes, and installationRedirectUrl on
the App literal built from a CIMD document. Those three became required
on Models.App in SDK 16 and a CIMD document carries none of them, so
they take the same empty defaults as the other fields the document
does not provide.
This commit is contained in:
harsh mahajan committed 2026-08-17 15:56:53 +05:30
1 parent a97d8874e1
commit 1cc7e263bd
2 files changed
+9 -1

No files matched your search

+3
View File
@@ -69,6 +69,7 @@ export function cimdDocumentToApp(clientId: string, document: unknown): Models.A
: [],
tagline: '',
tags: [],
labels: [],
images: [],
supportUrl: '',
dataDeletionUrl: '',
@@ -83,6 +84,8 @@ export function cimdDocumentToApp(clientId: string, document: unknown): Models.A
deviceFlow: Array.isArray(doc.grant_types) && doc.grant_types.includes(DEVICE_GRANT_TYPE),
teamId: '',
userId: '',
installationScopes: [],
installationRedirectUrl: '',
secrets: []
};
}
@@ -5,6 +5,7 @@
import { Dependencies } from '$lib/constants';
import { Button, Form } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { canWriteProjects } from '$lib/stores/roles';
import { sdk } from '$lib/stores/sdk';
import { Selector } from '@appwrite.io/pink-svelte';
import type { Models } from '@appwrite.io/console';
@@ -63,25 +64,29 @@
id="mfaFactorTotp"
label="TOTP"
description="Time-based codes from an authenticator app"
disabled={!$canWriteProjects}
bind:checked={totp} />
<Selector.Checkbox
id="mfaFactorEmail"
label="Email"
description="Codes sent to the user's verified email address"
disabled={!$canWriteProjects}
bind:checked={email} />
<Selector.Checkbox
id="mfaFactorPhone"
label="Phone"
description="Codes sent to the user's verified phone number over SMS"
disabled={!$canWriteProjects}
bind:checked={phone} />
<Selector.Checkbox
id="mfaFactorCustom"
label="Custom"
description="Appwrite generates and verifies the code, and you deliver it through your own channel"
disabled={!$canWriteProjects}
bind:checked={custom} />
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={isSubmitDisabled} submit>Update</Button>
<Button disabled={!$canWriteProjects || isSubmitDisabled} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>