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/project-invite-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/*6Project invite tokens. If a user presents one of these tokens and it is7not expired and the counter hasn't hit the usage_limit, then they get added8as a collaborator to the given project.9*/1011import { Table } from "./types";1213export interface ProjectInviteToken {14token: string;15project_id: string;16created: Date;17expires?: Date;18usage_limit?: number;19counter?: number;20}2122Table({23name: "project_invite_tokens",24fields: {25token: {26type: "string",27desc: "random unique id (intention: this is a random string)",28},29project_id: {30type: "uuid",31desc: "project_id of the project that this token provides access to",32},33created: {34type: "timestamp",35desc:36"when this token was created (just used for user convenience so no sanity checking)",37},38expires: {39type: "timestamp",40desc: "when this token expires",41},42usage_limit: {43type: "number",44desc: "how many times this token can be used",45},46counter: {47type: "number",48desc: "how many times this token has been used",49},50},51rules: {52primary_key: "token",53pg_indexes: ["project_id"],54user_query: {55get: {56options: [{ order_by: "-created" }],57pg_where: ["projects"],58fields: {59project_id: null,60token: null,61expires: null,62created: null,63usage_limit: null,64counter: null,65},66},67set: {68fields: {69project_id: "project_write",70token: null,71expires: null,72created: null,73usage_limit: null,74},75required_fields: {76project_id: true,77token: true,78},79},80},81},82});838485