Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/util/db-schema/registration-tokens.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45// An account token is a piece of additional information,6// which might be necessary to create an account.7// In the future, this might be extended to dispatch some action,8// like adding a student to a course, similar to account creation actions.910import {11Table,12RegistrationTokenSetFields,13RegistrationTokenGetFields,14} from "./types";1516// this covers 3 cases: selecting all, updating one, and deleting one17async function instead_of_query(db, opts: any, cb: Function): Promise<void> {18const { options, query } = opts;19try {20cb(undefined, await db.registrationTokens(options, query));21} catch (err) {22cb(err);23}24}2526Table({27name: "registration_tokens",28rules: {29primary_key: "token",30anonymous: false,31user_query: {32set: {33admin: true,34instead_of_query,35delete: true,36fields: {37token: null,38descr: null,39expires: null,40limit: null,41disabled: null,42} as { [key in RegistrationTokenSetFields]: null },43},44get: {45admin: true,46instead_of_query,47pg_where: [], // no limits48fields: {49token: null,50descr: null,51expires: null,52counter: null,53limit: null,54disabled: null,55} as { [key in RegistrationTokenGetFields]: null },56},57},58},59fields: {60token: { type: "string" },61descr: { type: "string" },62counter: { type: "number", desc: "how many accounts are created" },63expires: {64type: "timestamp",65desc: "optional – the time, when this token is no longer valid",66},67limit: { type: "number", desc: "optional – maximum number of accounts" },68disabled: { type: "boolean", desc: "set to true to disable this token" },69},70});717273