mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
Minting the state, building the consent URL and dropping a grant each had a copy per provider route. The routes keep their auth, rate limits and redirects and hand the rest to one implementation, which the managed-profile routes reuse.
19 lines
634 B
TypeScript
19 lines
634 B
TypeScript
import { apiHandler, requireAuth } from "@/lib/api-handler";
|
|
import { disconnectOAuth } from "@/lib/integrations/oauth-kit/disconnect";
|
|
import { apiSuccess, apiError } from "@/lib/api-response";
|
|
import { annotate } from "@/lib/logging/context";
|
|
|
|
/**
|
|
* Disconnect Withings integration for the current user.
|
|
*/
|
|
export const POST = apiHandler(async () => {
|
|
const { user } = await requireAuth();
|
|
annotate({ action: { name: "withings.disconnect" } });
|
|
|
|
if ((await disconnectOAuth("withings", user.id)) === "not_connected") {
|
|
return apiError("No Withings connection", 404);
|
|
}
|
|
|
|
return apiSuccess({ disconnected: true });
|
|
});
|