Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
PR suggestions
  • Loading branch information
Emyrk committed Dec 5, 2023
commit ad5587ab4b810407015db4597b6160b534dd4b2c
3 changes: 0 additions & 3 deletions site/src/api/queries/externalauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ export const userExternalAuth = (providerID: string) => {
export const validateExternalAuth = (_: QueryClient) => {
return {
mutationFn: API.getExternalAuthProvider,
onSuccess: async () => {
// No invalidation needed.
},
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const UserExternalAuthSettingsPage: FC = () => {
...mutateParams,
onSuccess: async () => {
await mutateParams.onSuccess();
await refetch();
setUnlinked(unlinked + 1);
},
});

Expand All @@ -49,17 +47,14 @@ const UserExternalAuthSettingsPage: FC = () => {
}}
onValidateExternalAuth={async (providerID: string) => {
try {
await validateAppMutation.mutateAsync(providerID, {
onSuccess: (data) => {
if (data.authenticated) {
displaySuccess("Application link is valid.");
} else {
displayError(
"Application link is not valid. Please unlink the application and reauthenticate.",
);
}
},
});
const data = await validateAppMutation.mutateAsync(providerID);
if (data.authenticated) {
displaySuccess("Application link is valid.");
} else {
displayError(
"Application link is not valid. Please unlink the application and reauthenticate.",
);
}
} catch (e) {
displayError(
getErrorMessage(e, "Error validating application link."),
Expand All @@ -83,7 +78,14 @@ const UserExternalAuthSettingsPage: FC = () => {
onConfirm={async () => {
try {
await unlinkAppMutation.mutateAsync(appToUnlink!);
// setAppToUnlink closes the modal
setAppToUnlink(undefined);
// refetch repopulates the external auth data
await refetch();
// this tells our child components to refetch their data
// as at least 1 provider was unlinked.
setUnlinked(unlinked + 1);

displaySuccess("Successfully unlinked the oauth2 application.");
} catch (e) {
displayError(getErrorMessage(e, "Error unlinking application."));
Expand Down