CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/auth/unlink-strategy.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/* api call to unlink a specific single sign on for the currently authenticated user */
7
8
import unlinkStrategy from "@cocalc/server/auth/sso/unlink-strategy";
9
import getAccountId from "lib/account/get-account";
10
import getParams from "lib/api/get-params";
11
import { OkStatus } from "lib/api/status";
12
13
export default async function handle(req, res) {
14
try {
15
const account_id = await getAccountId(req);
16
if (!account_id) {
17
throw Error("must be signed in");
18
}
19
const { name } = getParams(req);
20
await unlinkStrategy({ account_id, name });
21
res.json(OkStatus);
22
} catch (err) {
23
res.json({ error: err.message });
24
}
25
}
26
27