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/hub/utils.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { callback2 } from "@cocalc/util/async-utils";
7
import type { PostgreSQL } from "@cocalc/database/postgres/types";
8
import { PassportStrategyDB } from "@cocalc/database/settings/auth-sso-types";
9
10
export async function have_active_registration_tokens(
11
db: PostgreSQL,
12
): Promise<boolean> {
13
const resp = await callback2(db._query, {
14
query:
15
"SELECT EXISTS(SELECT 1 FROM registration_tokens WHERE disabled IS NOT true) AS have_tokens",
16
cache: true,
17
});
18
return resp.rows[0]?.have_tokens === true;
19
}
20
21
export async function get_passports(
22
db: PostgreSQL,
23
): Promise<PassportStrategyDB[]> {
24
return await db.get_all_passport_settings_cached();
25
}
26
27