aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/http/user.ts
diff options
context:
space:
mode:
Diffstat (limited to 'FrontEnd/src/app/http/user.ts')
-rw-r--r--FrontEnd/src/app/http/user.ts46
1 files changed, 45 insertions, 1 deletions
diff --git a/FrontEnd/src/app/http/user.ts b/FrontEnd/src/app/http/user.ts
index a0a02cce..9ba6508f 100644
--- a/FrontEnd/src/app/http/user.ts
+++ b/FrontEnd/src/app/http/user.ts
@@ -12,10 +12,18 @@ import {
convertToNotModified,
} from "./common";
+export const kUserPermissionList = [
+ "UserManagement",
+ "AllTimelineManagement",
+ "HighlightTimelineManagement",
+] as const;
+
+export type UserPermission = typeof kUserPermissionList[number];
+
export interface HttpUser {
uniqueId: string;
username: string;
- administrator: boolean;
+ permissions: UserPermission[];
nickname: string;
}
@@ -54,6 +62,16 @@ export interface IHttpUserClient {
): Promise<BlobWithEtag | NotModified>;
putAvatar(username: string, data: Blob, token: string): Promise<void>;
changePassword(req: HttpChangePasswordRequest, token: string): Promise<void>;
+ putUserPermission(
+ username: string,
+ permission: UserPermission,
+ token: string
+ ): Promise<void>;
+ deleteUserPermission(
+ username: string,
+ permission: UserPermission,
+ token: string
+ ): Promise<void>;
}
export class HttpUserClient implements IHttpUserClient {
@@ -119,6 +137,32 @@ export class HttpUserClient implements IHttpUserClient {
.catch(convertToNetworkError)
.then();
}
+
+ putUserPermission(
+ username: string,
+ permission: UserPermission,
+ token: string
+ ): Promise<void> {
+ return axios
+ .put(
+ `${apiBaseUrl}/users/${username}/permissions/${permission}?token=${token}`
+ )
+ .catch(convertToNetworkError)
+ .then();
+ }
+
+ deleteUserPermission(
+ username: string,
+ permission: UserPermission,
+ token: string
+ ): Promise<void> {
+ return axios
+ .delete(
+ `${apiBaseUrl}/users/${username}/permissions/${permission}?token=${token}`
+ )
+ .catch(convertToNetworkError)
+ .then();
+ }
}
let client: IHttpUserClient = new HttpUserClient();