Added frontend api for Admin Panel

This commit is contained in:
Mutzi 2022-08-25 20:42:53 +02:00
parent f8ccebc5ad
commit 1884a232f4
2 changed files with 56 additions and 0 deletions

55
frontend/src/api/admin.ts Normal file
View File

@ -0,0 +1,55 @@
import { Requests, Responses, UserRole } from 'dto';
import { get_token, post_token } from './base';
export const get_users = (token: string): Promise<Responses.Admin.GetUsers> =>
get_token('/api/admin/users', token);
export const set_role = (
user: number,
role: UserRole,
token: string
): Promise<Responses.Admin.SetUserRole> =>
post_token<Requests.Admin.SetUserRole>(
'/api/admin/set_role',
{
user,
role
},
token
);
export const logout = (
user: number,
token: string
): Promise<Responses.Admin.LogoutAllUser> =>
post_token<Requests.Admin.LogoutAll>(
'/api/admin/logout',
{
user
},
token
);
export const delete_user = (
user: number,
token: string
): Promise<Responses.Admin.DeleteUser> =>
post_token<Requests.Admin.DeleteUser>(
'/api/admin/delete',
{
user
},
token
);
export const disable_tfa = (
user: number,
token: string
): Promise<Responses.Admin.DisableTfa> =>
post_token<Requests.Admin.DisableTfa>(
'/api/admin/disable_2fa',
{
user
},
token
);

View File

@ -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';