From 1cc7e263bd33940585b8e6bfb7a2eb513f564037 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 17 Aug 2026 15:56:53 +0530 Subject: [PATCH] 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. --- src/lib/helpers/oauth2-cimd.ts | 3 +++ .../auth/security/updateMfaFactors.svelte | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/helpers/oauth2-cimd.ts b/src/lib/helpers/oauth2-cimd.ts index 7d631f678..e9ec0c288 100644 --- a/src/lib/helpers/oauth2-cimd.ts +++ b/src/lib/helpers/oauth2-cimd.ts @@ -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: [] }; } diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/updateMfaFactors.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/updateMfaFactors.svelte index ff4c37bb5..b435aad41 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/updateMfaFactors.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/updateMfaFactors.svelte @@ -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} /> - +