Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

set theme

Maksim Mrug9ca2f77e5bec
diff --git a/src/user/entities/user.entity.ts b/src/user/entities/user.entity.ts
index 6785c39e4..62a919f33 100644
--- a/src/user/entities/user.entity.ts
+++ b/src/user/entities/user.entity.ts
@@ -69,6 +69,11 @@ export enum BillingFrequency {
Yearly = 'yearly',
}
+export enum Theme {
+ classic = 'classic',
+ christmas = 'christmas',
+}
+
export const MAX_EMAIL_REQUESTS = 4 // 1 confirmation email on sign up + 3 additional ones
export const DEFAULT_TIMEZONE = 'Etc/GMT'
@@ -145,6 +150,10 @@ export class User {
@Column('varchar', { length: 30, nullable: true })
twoFactorRecoveryCode: string
+ // column for theme christmas and classic
+ @Column('varchar', { length: 50, default: Theme.classic })
+ theme: Theme
+
@Column({ default: false })
isTwoFactorAuthenticationEnabled: boolean
diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts
index c7e204567..db8131f3c 100644
--- a/src/user/user.controller.ts
+++ b/src/user/user.controller.ts
@@ -36,6 +36,7 @@ import {
UserType,
MAX_EMAIL_REQUESTS,
PlanCode,
+ Theme,
} from './entities/user.entity'
import { Roles } from '../common/decorators/roles.decorator'
import { Pagination } from '../common/pagination/pagination'
@@ -83,6 +84,18 @@ export class UserController {
return await this.userService.paginate({ take, skip })
}
+ // set theme
+ @Put('/:id/theme')
+ @UseGuards(RolesGuard)
+ @UseGuards(SelfhostedGuard)
+ @Roles(UserType.CUSTOMER, UserType.ADMIN)
+ async setTheme(
+ @Param('id') id: string,
+ @Body('theme') theme: Theme,
+ ): Promise<User> {
+ return await this.userService.update(id, { theme })
+ }
+
@Get('/search')
@ApiQuery({ name: 'query', required: false })
@UseGuards(RolesGuard)