Fix invalid token after credentials change (#4717)

- If sync fails we set authFailedAt
- This information is displayed in the frontend in accounts with a `Sync
Failed` pill
- The user can reconnect his account in the dropdown menu
- A new OAuth flow is triggered
- The account is synced
This commit is contained in:
bosiraphael
2024-04-02 11:32:27 +02:00
committed by GitHub
parent a3a15957f4
commit ffb1733f39
18 changed files with 318 additions and 123 deletions

View File

@ -150,4 +150,20 @@ export class ConnectedAccountRepository {
transactionManager,
);
}
public async updateAuthFailedAt(
connectedAccountId: string,
workspaceId: string,
transactionManager?: EntityManager,
) {
const dataSourceSchema =
this.workspaceDataSourceService.getSchemaName(workspaceId);
await this.workspaceDataSourceService.executeRawQuery(
`UPDATE ${dataSourceSchema}."connectedAccount" SET "authFailedAt" = NOW() WHERE "id" = $1`,
[connectedAccountId],
workspaceId,
transactionManager,
);
}
}