mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-30 11:16:35 +00:00
feat: add user groups
This commit is contained in:
@@ -13,7 +13,7 @@ abstract class APIService {
|
||||
if (browser) {
|
||||
this.api.defaults.baseURL = '/api';
|
||||
} else {
|
||||
this.api.defaults.baseURL = process?.env?.INTERNAL_BACKEND_URL + '/api';
|
||||
this.api.defaults.baseURL = process!.env!.INTERNAL_BACKEND_URL + '/api';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,8 @@ import APIService from './api-service';
|
||||
|
||||
class AuditLogService extends APIService {
|
||||
async list(pagination?: PaginationRequest) {
|
||||
const page = pagination?.page || 1;
|
||||
const limit = pagination?.limit || 10;
|
||||
|
||||
const res = await this.api.get('/audit-logs', {
|
||||
params: {
|
||||
page,
|
||||
limit
|
||||
}
|
||||
params: pagination
|
||||
});
|
||||
return res.data as Paginated<AuditLog>;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { Paginated, PaginationRequest } from '$lib/types/pagination.type';
|
||||
import APIService from './api-service';
|
||||
|
||||
class OidcService extends APIService {
|
||||
async authorize(clientId: string, scope: string, callbackURL : string, nonce?: string) {
|
||||
async authorize(clientId: string, scope: string, callbackURL: string, nonce?: string) {
|
||||
const res = await this.api.post('/oidc/authorize', {
|
||||
scope,
|
||||
nonce,
|
||||
@@ -26,14 +26,10 @@ class OidcService extends APIService {
|
||||
}
|
||||
|
||||
async listClients(search?: string, pagination?: PaginationRequest) {
|
||||
const page = pagination?.page || 1;
|
||||
const limit = pagination?.limit || 10;
|
||||
|
||||
const res = await this.api.get('/oidc/clients', {
|
||||
params: {
|
||||
search,
|
||||
page,
|
||||
limit
|
||||
...pagination
|
||||
}
|
||||
});
|
||||
return res.data as Paginated<OidcClient>;
|
||||
|
||||
43
frontend/src/lib/services/user-group-service.ts
Normal file
43
frontend/src/lib/services/user-group-service.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { Paginated, PaginationRequest } from '$lib/types/pagination.type';
|
||||
import type {
|
||||
UserGroupCreate,
|
||||
UserGroupWithUserCount,
|
||||
UserGroupWithUsers
|
||||
} from '$lib/types/user-group.type';
|
||||
import APIService from './api-service';
|
||||
|
||||
export default class UserGroupService extends APIService {
|
||||
async list(search?: string, pagination?: PaginationRequest) {
|
||||
const res = await this.api.get('/user-groups', {
|
||||
params: {
|
||||
search,
|
||||
...pagination
|
||||
}
|
||||
});
|
||||
return res.data as Paginated<UserGroupWithUserCount>;
|
||||
}
|
||||
|
||||
async get(id: string) {
|
||||
const res = await this.api.get(`/user-groups/${id}`);
|
||||
return res.data as UserGroupWithUsers;
|
||||
}
|
||||
|
||||
async create(user: UserGroupCreate) {
|
||||
const res = await this.api.post('/user-groups', user);
|
||||
return res.data as UserGroupWithUsers;
|
||||
}
|
||||
|
||||
async update(id: string, user: UserGroupCreate) {
|
||||
const res = await this.api.put(`/user-groups/${id}`, user);
|
||||
return res.data as UserGroupWithUsers;
|
||||
}
|
||||
|
||||
async remove(id: string) {
|
||||
await this.api.delete(`/user-groups/${id}`);
|
||||
}
|
||||
|
||||
async updateUsers(id: string, userIds: string[]) {
|
||||
const res = await this.api.put(`/user-groups/${id}/users`, { userIds });
|
||||
return res.data as UserGroupWithUsers;
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,10 @@ import APIService from './api-service';
|
||||
|
||||
export default class UserService extends APIService {
|
||||
async list(search?: string, pagination?: PaginationRequest) {
|
||||
const page = pagination?.page || 1;
|
||||
const limit = pagination?.limit || 10;
|
||||
|
||||
const res = await this.api.get('/users', {
|
||||
params: {
|
||||
search,
|
||||
page,
|
||||
limit
|
||||
...pagination
|
||||
}
|
||||
});
|
||||
return res.data as Paginated<User>;
|
||||
|
||||
Reference in New Issue
Block a user