mirror of
https://github.com/hay-kot/mealie.git
synced 2025-07-11 15:47:13 -07:00
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:
parent
e0d7341139
commit
63a362a48a
9 changed files with 148 additions and 8 deletions
|
@ -238,6 +238,10 @@ export interface UserIn {
|
|||
canOrganize?: boolean;
|
||||
password: string;
|
||||
}
|
||||
export interface UserSummary {
|
||||
id: string;
|
||||
fullName?: string;
|
||||
}
|
||||
export interface ValidateResetToken {
|
||||
token: string;
|
||||
}
|
||||
|
|
|
@ -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, {});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue