fix: Limit shopping list owners to current group (#3305)

* add route for getting group-only users

* add new api route to frontend

* update shopping list user getAll call

* tests

* fixed bad import

* replace UserOut with UserSummary

* fix params
This commit is contained in:
Michael Genson 2024-03-13 13:29:00 -05:00 committed by GitHub
parent e0d7341139
commit 63a362a48a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 148 additions and 8 deletions

View file

@ -238,6 +238,10 @@ export interface UserIn {
canOrganize?: boolean;
password: string;
}
export interface UserSummary {
id: string;
fullName?: string;
}
export interface ValidateResetToken {
token: string;
}

View file

@ -1,5 +1,6 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { RequestResponse } from "../types/non-generated";
import { QueryValue, route } from "~/lib/api/base/route";
import { PaginationData, RequestResponse } from "~/lib/api/types/non-generated";
import {
ChangePassword,
DeleteTokenResponse,
@ -11,11 +12,13 @@ import {
UserFavorites,
UserIn,
UserOut,
UserSummary,
} from "~/lib/api/types/user";
const prefix = "/api";
const routes = {
groupUsers: `${prefix}/users/group-users`,
usersSelf: `${prefix}/users/self`,
groupsSelf: `${prefix}/users/self/group`,
passwordReset: `${prefix}/users/reset-password`,
@ -36,6 +39,10 @@ export class UserApi extends BaseCRUDAPI<UserIn, UserOut, UserBase> {
baseRoute: string = routes.users;
itemRoute = (itemid: string) => routes.usersId(itemid);
async getGroupUsers(page = 1, perPage = -1, params = {} as Record<string, QueryValue>) {
return await this.requests.get<PaginationData<UserSummary>>(route(routes.groupUsers, { page, perPage, ...params }));
}
async getSelfGroup(): Promise<RequestResponse<GroupInDB>> {
return await this.requests.get(routes.groupsSelf, {});
}