mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 00:12:18 +00:00
fix(integrations): one provider account per record, borrowed apps return
A guardian finishing a connect for a managed profile could attach their own provider account to the profile. Every OAuth callback (Withings, WHOOP, Fitbit, Google Health, Strava, Polar, Oura) now refuses a provider account another record already holds with reason already_linked, shown as its own message on the integrations page. WHOOP's owner_conflict tag becomes already_linked as well. Oura keeps the account id of a grant (personal_info, migration 0441) so the check has something to compare; existing connections fill it at their next connect. A disconnect leaves Withings webhook subscriptions and the Strava app authorisation in place while another record holds the same account, and the Withings webhook routes an account held twice to the record that linked it first instead of whichever row a lookup returned. The provider app copied from a guardian onto a managed profile is now marked (migration 0442) and removed again on disconnect or when that guardian no longer holds a live MANAGE grant: revoke, renounce, removal, handover, account deletion and data wipe. Each removal is audited as integration.client_app.removed.
This commit is contained in:
1 parent
e1b70537cc
commit
e0eaed2251
43 files changed
+1168
-157
No files matched your search
@@ -80,6 +80,27 @@ describe("oauthReasonKey", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("names an account already held by another record for every provider", async () => {
|
||||
const en = (await import("../../../../messages/en.json"))
|
||||
.default as unknown as {
|
||||
settings: Record<string, Record<string, string>>;
|
||||
};
|
||||
for (const provider of [
|
||||
"polar",
|
||||
"oura",
|
||||
"whoop",
|
||||
"fitbit",
|
||||
"googleHealth",
|
||||
"strava",
|
||||
] as const) {
|
||||
const key = oauthReasonKey(provider, "already_linked");
|
||||
expect(key.endsWith(".already_linked")).toBe(true);
|
||||
const [, base] = key.split(".");
|
||||
expect(en.settings[base!]!.already_linked).toBeTruthy();
|
||||
}
|
||||
expect(en.settings.withingsOauthError!.already_linked).toBeTruthy();
|
||||
});
|
||||
|
||||
it("falls back to generic for an unknown tag", () => {
|
||||
expect(oauthReasonKey("whoop", "totally_unknown")).toBe(
|
||||
"settings.whoopOauthError.generic",
|
||||
|
||||
@@ -57,6 +57,7 @@ const WITHINGS_OAUTH_ERROR_KEYS: Record<string, string> = {
|
||||
nocode: "settings.withingsOauthError.nocode",
|
||||
nocreds: "settings.withingsOauthError.nocreds",
|
||||
token: "settings.withingsOauthError.token",
|
||||
already_linked: "settings.withingsOauthError.already_linked",
|
||||
};
|
||||
|
||||
type WithingsOauthOutcome =
|
||||
@@ -126,6 +127,8 @@ const OAUTH_OUTCOME_REASONS = new Set([
|
||||
"token",
|
||||
"rate_limited",
|
||||
"expired",
|
||||
// The provider account is already connected to another record.
|
||||
"already_linked",
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user