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/has-password.ts
Views: 687
1
/* API endpoint to determine whether or not the currently authenticated
2
user has a passport. */
3
4
import getAccountId from "lib/account/get-account";
5
import hasPassword from "@cocalc/server/auth/has-password";
6
7
export default async function handle(req, res) {
8
try {
9
const account_id = await getAccountId(req);
10
if (!account_id) {
11
throw Error("must be signed in");
12
}
13
res.json({ hasPassword: await hasPassword(account_id) });
14
} catch (err) {
15
res.json({ error: err.message });
16
}
17
}
18
19