From 1884a232f4d35bf93eb33f079086a6936e096c82 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 25 Aug 2022 20:42:53 +0200 Subject: [PATCH] Added frontend api for Admin Panel --- frontend/src/api/admin.ts | 55 +++++++++++++++++++++++++++++++++++++++ frontend/src/api/index.ts | 1 + 2 files changed, 56 insertions(+) create mode 100644 frontend/src/api/admin.ts diff --git a/frontend/src/api/admin.ts b/frontend/src/api/admin.ts new file mode 100644 index 0000000..d3fdfc1 --- /dev/null +++ b/frontend/src/api/admin.ts @@ -0,0 +1,55 @@ +import { Requests, Responses, UserRole } from 'dto'; +import { get_token, post_token } from './base'; + +export const get_users = (token: string): Promise => + get_token('/api/admin/users', token); + +export const set_role = ( + user: number, + role: UserRole, + token: string +): Promise => + post_token( + '/api/admin/set_role', + { + user, + role + }, + token + ); + +export const logout = ( + user: number, + token: string +): Promise => + post_token( + '/api/admin/logout', + { + user + }, + token + ); + +export const delete_user = ( + user: number, + token: string +): Promise => + post_token( + '/api/admin/delete', + { + user + }, + token + ); + +export const disable_tfa = ( + user: number, + token: string +): Promise => + post_token( + '/api/admin/disable_2fa', + { + user + }, + token + ); diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index 29c0f1d..ab67b3e 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -4,4 +4,5 @@ export { isErrorResponse } from './base'; export * as Auth from './auth'; export * as FS from './fs'; export * as User from './user'; +export * as Admin from './admin'; export * from './util';