From 85ab35244362b0e38314599019501d57daf86d77 Mon Sep 17 00:00:00 2001 From: Georg Bremer Date: Wed, 8 May 2024 14:00:00 +0200 Subject: [PATCH] fix: Handle invitation links with invalid auth token When following an invitation link with an old auth token, we would just show an ugly error message and don't give the user an action to do. Sign them out if we get the 'notSignedIn' error. --- packages/client/mutations/AcceptTeamInvitationMutation.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/client/mutations/AcceptTeamInvitationMutation.ts b/packages/client/mutations/AcceptTeamInvitationMutation.ts index d34825bfd41..9fedfcb8b06 100644 --- a/packages/client/mutations/AcceptTeamInvitationMutation.ts +++ b/packages/client/mutations/AcceptTeamInvitationMutation.ts @@ -215,7 +215,10 @@ const AcceptTeamInvitationMutation: StandardMutation< const serverError = getGraphQLError(data, errors) if (serverError) { const message = serverError.message - if (message === InvitationTokenError.ALREADY_ACCEPTED) { + if (message === InvitationTokenError.NOT_SIGNED_IN) { + // if the user follows an invitation link with an invalid auth token, invalidate it + atmosphere.setAuthToken(null) + } else if (message === InvitationTokenError.ALREADY_ACCEPTED) { handleAuthenticationRedirect(acceptTeamInvitation, { atmosphere, history,