(core) Removing temporary pro site

Summary: Creating a pro team site after Stripe checkout. Previously a stub site was always created and never removed, even if a user cancels the checkout process, which resulted in multiple 'ghost' sites that can't be removed.

Test Plan: Updated and added

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3985
This commit is contained in:
Jarosław Sadziński
2023-08-09 10:35:44 +02:00
parent f1a0b61e15
commit fad421b7c0
3 changed files with 44 additions and 16 deletions

View File

@@ -7,6 +7,8 @@ import {Request} from 'express';
import {ApiError} from 'app/common/ApiError';
import {FullUser} from 'app/common/LoginSessionAPI';
import {OrganizationProperties} from 'app/common/UserAPI';
import {User} from 'app/gen-server/entity/User';
import {BillingOptions, HomeDBManager, QueryResult, Scope} from 'app/gen-server/lib/HomeDBManager';
import {getAuthorizedUserId, getUserId, getUserProfiles, RequestWithLogin} from 'app/server/lib/Authorizer';
import {getSessionUser, linkOrgWithEmail} from 'app/server/lib/BrowserSession';
import {expressWrap} from 'app/server/lib/expressWrap';
@@ -16,9 +18,6 @@ import log from 'app/server/lib/log';
import {addPermit, clearSessionCacheIfNeeded, getDocScope, getScope, integerParam,
isParameterOn, optStringParam, sendOkReply, sendReply, stringParam} from 'app/server/lib/requestUtils';
import {IWidgetRepository} from 'app/server/lib/WidgetRepository';
import {User} from './entity/User';
import {HomeDBManager, QueryResult, Scope} from './lib/HomeDBManager';
import {getCookieDomain} from 'app/server/lib/gristSessions';
// exposed for testing purposes
@@ -64,7 +63,7 @@ export function getOrgKey(req: Request): string|number {
return orgKey;
}
// Adds an non-personal org with a new billingAccout, with the given name and domain.
// Adds an non-personal org with a new billingAccount, with the given name and domain.
// Returns a QueryResult with the orgId on success.
export function addOrg(
dbManager: HomeDBManager,
@@ -72,6 +71,7 @@ export function addOrg(
props: Partial<OrganizationProperties>,
options?: {
planType?: string,
billing?: BillingOptions,
}
): Promise<number> {
return dbManager.connection.transaction(async manager => {