feat: Allow hideBranding via public API (#11978)
parent
614741d207
commit
4b818de0c8
|
@ -75,6 +75,7 @@ export const schemaUserBaseBodyParams = User.pick({
|
||||||
theme: true,
|
theme: true,
|
||||||
defaultScheduleId: true,
|
defaultScheduleId: true,
|
||||||
locale: true,
|
locale: true,
|
||||||
|
hideBranding: true,
|
||||||
timeFormat: true,
|
timeFormat: true,
|
||||||
brandColor: true,
|
brandColor: true,
|
||||||
darkBrandColor: true,
|
darkBrandColor: true,
|
||||||
|
@ -95,6 +96,7 @@ const schemaUserEditParams = z.object({
|
||||||
weekStart: z.nativeEnum(weekdays).optional(),
|
weekStart: z.nativeEnum(weekdays).optional(),
|
||||||
brandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
brandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
||||||
darkBrandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
darkBrandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
||||||
|
hideBranding: z.boolean().optional(),
|
||||||
timeZone: timeZone.optional(),
|
timeZone: timeZone.optional(),
|
||||||
theme: z.nativeEnum(theme).optional().nullable(),
|
theme: z.nativeEnum(theme).optional().nullable(),
|
||||||
timeFormat: z.nativeEnum(timeFormat).optional(),
|
timeFormat: z.nativeEnum(timeFormat).optional(),
|
||||||
|
@ -115,6 +117,7 @@ const schemaUserCreateParams = z.object({
|
||||||
weekStart: z.nativeEnum(weekdays).optional(),
|
weekStart: z.nativeEnum(weekdays).optional(),
|
||||||
brandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
brandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
||||||
darkBrandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
darkBrandColor: z.string().min(4).max(9).regex(/^#/).optional(),
|
||||||
|
hideBranding: z.boolean().optional(),
|
||||||
timeZone: timeZone.optional(),
|
timeZone: timeZone.optional(),
|
||||||
theme: z.nativeEnum(theme).optional().nullable(),
|
theme: z.nativeEnum(theme).optional().nullable(),
|
||||||
timeFormat: z.nativeEnum(timeFormat).optional(),
|
timeFormat: z.nativeEnum(timeFormat).optional(),
|
||||||
|
@ -157,6 +160,7 @@ export const schemaUserReadPublic = User.pick({
|
||||||
defaultScheduleId: true,
|
defaultScheduleId: true,
|
||||||
locale: true,
|
locale: true,
|
||||||
timeFormat: true,
|
timeFormat: true,
|
||||||
|
hideBranding: true,
|
||||||
brandColor: true,
|
brandColor: true,
|
||||||
darkBrandColor: true,
|
darkBrandColor: true,
|
||||||
allowDynamicBooking: true,
|
allowDynamicBooking: true,
|
||||||
|
|
|
@ -53,6 +53,9 @@ import { schemaUserEditBodyParams, schemaUserReadPublic } from "~/lib/validation
|
||||||
* timeZone:
|
* timeZone:
|
||||||
* description: The user's time zone
|
* description: The user's time zone
|
||||||
* type: string
|
* type: string
|
||||||
|
* hideBranding:
|
||||||
|
* description: Remove branding from the user's calendar page
|
||||||
|
* type: boolean
|
||||||
* theme:
|
* theme:
|
||||||
* description: Default theme for the user. Acceptable values are one of [DARK, LIGHT]
|
* description: Default theme for the user. Acceptable values are one of [DARK, LIGHT]
|
||||||
* type: string
|
* type: string
|
||||||
|
@ -79,7 +82,7 @@ import { schemaUserEditBodyParams, schemaUserReadPublic } from "~/lib/validation
|
||||||
* - users
|
* - users
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: OK, user edited successfuly
|
* description: OK, user edited successfully
|
||||||
* 400:
|
* 400:
|
||||||
* description: Bad request. User body is invalid.
|
* description: Bad request. User body is invalid.
|
||||||
* 401:
|
* 401:
|
||||||
|
@ -94,9 +97,10 @@ export async function patchHandler(req: NextApiRequest) {
|
||||||
if (!isAdmin && query.userId !== req.userId) throw new HttpError({ statusCode: 403, message: "Forbidden" });
|
if (!isAdmin && query.userId !== req.userId) throw new HttpError({ statusCode: 403, message: "Forbidden" });
|
||||||
|
|
||||||
const body = await schemaUserEditBodyParams.parseAsync(req.body);
|
const body = await schemaUserEditBodyParams.parseAsync(req.body);
|
||||||
// disable role changes unless admin.
|
// disable role or branding changes unless admin.
|
||||||
if (!isAdmin && body.role) {
|
if (!isAdmin) {
|
||||||
body.role = undefined;
|
if (body.role) body.role = undefined;
|
||||||
|
if (body.hideBranding) body.hideBranding = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userSchedules = await prisma.schedule.findMany({
|
const userSchedules = await prisma.schedule.findMany({
|
||||||
|
|
|
@ -42,6 +42,9 @@ import { schemaUserCreateBodyParams } from "~/lib/validations/user";
|
||||||
* darkBrandColor:
|
* darkBrandColor:
|
||||||
* description: The new user's brand color for dark mode
|
* description: The new user's brand color for dark mode
|
||||||
* type: string
|
* type: string
|
||||||
|
* hideBranding:
|
||||||
|
* description: Remove branding from the user's calendar page
|
||||||
|
* type: boolean
|
||||||
* weekStart:
|
* weekStart:
|
||||||
* description: Start of the week. Acceptable values are one of [SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY]
|
* description: Start of the week. Acceptable values are one of [SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY]
|
||||||
* type: string
|
* type: string
|
||||||
|
|
Loading…
Reference in New Issue