@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
30 lines • 1.5 kB
JavaScript
;
// Do all the account creation actions for the given account. This should be called
// immediately after creating the account.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.creationActionsDone = void 0;
const pool_1 = __importDefault(require("@cocalc/database/pool"));
const add_user_to_project_1 = __importDefault(require("@cocalc/server/projects/add-user-to-project"));
async function accountCreationActions(email_address, account_id) {
const pool = (0, pool_1.default)();
const { rows } = await pool.query("SELECT action FROM account_creation_actions WHERE email_address=$1 AND expire > NOW()", [email_address]);
for (const { action } of rows) {
if (action.action == "add_to_project") {
const { project_id, group } = action;
await (0, add_user_to_project_1.default)({ project_id, account_id, group });
}
else {
throw Error(`unknown account creation action "${action.action}"`);
}
}
}
exports.default = accountCreationActions;
async function creationActionsDone(account_id) {
const pool = (0, pool_1.default)();
await pool.query("UPDATE accounts SET creation_actions_done=true WHERE account_id=$1::UUID", [account_id]);
}
exports.creationActionsDone = creationActionsDone;
//# sourceMappingURL=account-creation-actions.js.map