From ab2842a56c711d901bb958873a44e76d8f287803 Mon Sep 17 00:00:00 2001 From: Alexander Song Date: Wed, 2 Oct 2024 15:16:35 -0700 Subject: [PATCH] don't display password reset for oauth users --- app/src/contexts/ViewerContext.tsx | 1 + .../ViewerContextRefetchQuery.graphql.ts | 15 ++++++++++---- .../ViewerContext_viewer.graphql.ts | 13 ++++++++++-- .../authenticatedRootLoaderQuery.graphql.ts | 13 +++++++++--- app/src/pages/profile/ViewerProfileCard.tsx | 20 ++++++++++--------- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/app/src/contexts/ViewerContext.tsx b/app/src/contexts/ViewerContext.tsx index 93489bf0ac..8aee4999cb 100644 --- a/app/src/contexts/ViewerContext.tsx +++ b/app/src/contexts/ViewerContext.tsx @@ -42,6 +42,7 @@ export function ViewerProvider({ role { name } + authMethod ...APIKeysTableFragment } } diff --git a/app/src/contexts/__generated__/ViewerContextRefetchQuery.graphql.ts b/app/src/contexts/__generated__/ViewerContextRefetchQuery.graphql.ts index 7ddef9cfbd..99e2c564de 100644 --- a/app/src/contexts/__generated__/ViewerContextRefetchQuery.graphql.ts +++ b/app/src/contexts/__generated__/ViewerContextRefetchQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<9165c4bbcd695cd2e9608aa9143549ab>> * @lightSyntaxTransform * @nogrep */ @@ -98,6 +98,13 @@ return { ], "storageKey": null }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "authMethod", + "storageKey": null + }, { "alias": null, "args": null, @@ -138,16 +145,16 @@ return { ] }, "params": { - "cacheID": "4c8790abe3ec8e077913422cb62c6b3f", + "cacheID": "12e359dfec5f96fcfcbeff2e8110b80f", "id": null, "metadata": {}, "name": "ViewerContextRefetchQuery", "operationKind": "query", - "text": "query ViewerContextRefetchQuery {\n ...ViewerContext_viewer\n}\n\nfragment APIKeysTableFragment on User {\n apiKeys {\n id\n name\n description\n createdAt\n expiresAt\n }\n id\n}\n\nfragment ViewerContext_viewer on Query {\n viewer {\n id\n username\n email\n profilePictureUrl\n role {\n name\n }\n ...APIKeysTableFragment\n }\n}\n" + "text": "query ViewerContextRefetchQuery {\n ...ViewerContext_viewer\n}\n\nfragment APIKeysTableFragment on User {\n apiKeys {\n id\n name\n description\n createdAt\n expiresAt\n }\n id\n}\n\nfragment ViewerContext_viewer on Query {\n viewer {\n id\n username\n email\n profilePictureUrl\n role {\n name\n }\n authMethod\n ...APIKeysTableFragment\n }\n}\n" } }; })(); -(node as any).hash = "0fda3314d35e251b11f0ed180df72f44"; +(node as any).hash = "bec0ae2a629134a5b9afe1846eaec2c9"; export default node; diff --git a/app/src/contexts/__generated__/ViewerContext_viewer.graphql.ts b/app/src/contexts/__generated__/ViewerContext_viewer.graphql.ts index 2ea4af9dff..d5d7ecd258 100644 --- a/app/src/contexts/__generated__/ViewerContext_viewer.graphql.ts +++ b/app/src/contexts/__generated__/ViewerContext_viewer.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<4943c441f0a18f63c691a565344bcaf7>> * @lightSyntaxTransform * @nogrep */ @@ -9,9 +9,11 @@ // @ts-nocheck import { ReaderFragment, RefetchableFragment } from 'relay-runtime'; +export type AuthMethod = "LOCAL" | "OAUTH2"; import { FragmentRefs } from "relay-runtime"; export type ViewerContext_viewer$data = { readonly viewer: { + readonly authMethod: AuthMethod; readonly email: string; readonly id: string; readonly profilePictureUrl: string | null; @@ -96,6 +98,13 @@ const node: ReaderFragment = { ], "storageKey": null }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "authMethod", + "storageKey": null + }, { "args": null, "kind": "FragmentSpread", @@ -109,6 +118,6 @@ const node: ReaderFragment = { "abstractKey": null }; -(node as any).hash = "0fda3314d35e251b11f0ed180df72f44"; +(node as any).hash = "bec0ae2a629134a5b9afe1846eaec2c9"; export default node; diff --git a/app/src/pages/__generated__/authenticatedRootLoaderQuery.graphql.ts b/app/src/pages/__generated__/authenticatedRootLoaderQuery.graphql.ts index 708bfe0f57..0a9b4f7d87 100644 --- a/app/src/pages/__generated__/authenticatedRootLoaderQuery.graphql.ts +++ b/app/src/pages/__generated__/authenticatedRootLoaderQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<8b60e823c28195489be2e021960df6d6>> + * @generated SignedSource<<53a3f976f98fd4315fee6e61174280eb>> * @lightSyntaxTransform * @nogrep */ @@ -120,6 +120,13 @@ return { ], "storageKey": null }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "authMethod", + "storageKey": null + }, { "alias": null, "args": null, @@ -161,12 +168,12 @@ return { ] }, "params": { - "cacheID": "60c31f9b6cb4ed2cbdfcfe1c11255556", + "cacheID": "d63c6184305079deb38a6f6235ba88e6", "id": null, "metadata": {}, "name": "authenticatedRootLoaderQuery", "operationKind": "query", - "text": "query authenticatedRootLoaderQuery {\n ...ViewerContext_viewer\n viewer {\n passwordNeedsReset\n }\n}\n\nfragment APIKeysTableFragment on User {\n apiKeys {\n id\n name\n description\n createdAt\n expiresAt\n }\n id\n}\n\nfragment ViewerContext_viewer on Query {\n viewer {\n id\n username\n email\n profilePictureUrl\n role {\n name\n }\n ...APIKeysTableFragment\n }\n}\n" + "text": "query authenticatedRootLoaderQuery {\n ...ViewerContext_viewer\n viewer {\n passwordNeedsReset\n }\n}\n\nfragment APIKeysTableFragment on User {\n apiKeys {\n id\n name\n description\n createdAt\n expiresAt\n }\n id\n}\n\nfragment ViewerContext_viewer on Query {\n viewer {\n id\n username\n email\n profilePictureUrl\n role {\n name\n }\n authMethod\n ...APIKeysTableFragment\n }\n}\n" } }; })(); diff --git a/app/src/pages/profile/ViewerProfileCard.tsx b/app/src/pages/profile/ViewerProfileCard.tsx index 2a9c4d498b..1c4a41d78b 100644 --- a/app/src/pages/profile/ViewerProfileCard.tsx +++ b/app/src/pages/profile/ViewerProfileCard.tsx @@ -81,15 +81,17 @@ export function ViewerProfileCard() { variant="compact" bodyStyle={{ padding: 0 }} extra={ - + viewer.authMethod === "LOCAL" && ( + + ) } >