Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/client/admin.ts
1503 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import type { WebappClient } from "./client";
7
import api from "./api";
8
9
export class AdminClient {
10
private client: WebappClient;
11
12
constructor(client: WebappClient) {
13
this.client = client;
14
}
15
16
public async admin_ban_user(
17
account_id: string,
18
ban: boolean = true, // if true, ban user -- if false, remove ban
19
): Promise<void> {
20
if (ban) {
21
await api("/accounts/ban", { account_id });
22
} else {
23
await api("/accounts/remove-ban", { account_id });
24
}
25
}
26
27
public async get_user_auth_token(user_account_id: string): Promise<string> {
28
return await this.client.conat_client.hub.system.generateUserAuthToken({
29
user_account_id,
30
});
31
}
32
}
33
34