mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Allowing installation admins to manage billing.
Summary: Permissions for admin billing endpoints were changed - Support user can't use admin subscription endpoints - Installation admin (as support user) can see billing details on any site - Installation admin (unlike support user) can replace subscription (or attach payment) on any site, regardless permissions Installation admin is any user that belongs to a special `admin` org. If `admin` org is not defined, it defaults to support user. In that case, with this diff, the support user receives admin's permissions, and now can replace subscription on any site (without being billing manager). Test Plan: Added new test Reviewers: dsagal, paulfitz Reviewed By: dsagal, paulfitz Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D4338
This commit is contained in:
@@ -1810,12 +1810,13 @@ export class HomeDBManager extends EventEmitter {
|
||||
//
|
||||
// Returns an empty query result with status 200 on success.
|
||||
public async updateBillingAccount(
|
||||
userId: number,
|
||||
scopeOrUser: number|Scope,
|
||||
orgKey: string|number,
|
||||
callback: (billingAccount: BillingAccount, transaction: EntityManager) => void|Promise<void>
|
||||
): Promise<QueryResult<void>> {
|
||||
): Promise<QueryResult<void>> {
|
||||
return await this._connection.transaction(async transaction => {
|
||||
const billingAccount = await this.getBillingAccount({userId}, orgKey, false, transaction);
|
||||
const scope = typeof scopeOrUser === 'number' ? {userId: scopeOrUser} : scopeOrUser;
|
||||
const billingAccount = await this.getBillingAccount(scope, orgKey, false, transaction);
|
||||
const billingAccountCopy = Object.assign({}, billingAccount);
|
||||
await callback(billingAccountCopy, transaction);
|
||||
// Pick out properties that are allowed to be changed, to prevent accidental updating
|
||||
|
||||
Reference in New Issue
Block a user