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!

Match Cloud version changes

Blue Mouse44664adc8fc7
diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.ts
index c966ad7bc..a2a918788 100644
--- a/backend/apps/cloud/src/project/project.controller.ts
+++ b/backend/apps/cloud/src/project/project.controller.ts
@@ -190,7 +190,6 @@ export class ProjectController {
return {
...project,
- isOwner: project.admin.id === userId, // deprecated
isAccessConfirmed,
isLocked: !!project.admin?.dashboardBlockReason,
isDataExists: _includes(pidsWithData, project?.id),
@@ -1924,7 +1923,7 @@ export class ProjectController {
@ApiResponse({ status: 200, type: Project })
async getOne(
@Param('id') id: string,
- @CurrentUserId() uid: string,
+ @CurrentUserId() userId: string,
@Headers() headers: { 'x-password'?: string },
): Promise<Project | object> {
this.logger.log({ id }, 'GET /project/:id')
@@ -1945,7 +1944,7 @@ export class ProjectController {
let allowedToViewNoPassword = false
try {
- this.projectService.allowedToView(project, uid)
+ this.projectService.allowedToView(project, userId)
allowedToViewNoPassword = true
} catch {
allowedToViewNoPassword = false
@@ -1962,7 +1961,7 @@ export class ProjectController {
}
}
- this.projectService.allowedToView(project, uid, headers['x-password'])
+ this.projectService.allowedToView(project, userId, headers['x-password'])
const [isDataExists, isErrorDataExists] = await Promise.all([
!_isEmpty(
@@ -1974,13 +1973,13 @@ export class ProjectController {
let role
let isAccessConfirmed = true
- if (uid) {
- const userShare = project.share?.find(share => share.user?.id === uid)
+ if (userId) {
+ const userShare = project.share?.find(share => share.user?.id === userId)
const organisationMembership = project.organisation?.members?.find(
- member => member.user?.id === uid,
+ member => member.user?.id === userId,
)
- if (project.admin?.id === uid) {
+ if (project.admin?.id === userId) {
role = 'owner'
} else if (userShare) {
role = userShare.role
@@ -1998,7 +1997,6 @@ export class ProjectController {
'organisation',
role !== 'owner' && role !== 'admin' && 'share',
]),
- isOwner: uid === project.admin?.id, // deprecated
isAccessConfirmed,
isLocked: !!project.admin?.dashboardBlockReason,
isDataExists,
diff --git a/backend/apps/community/src/auth/auth.controller.ts b/backend/apps/community/src/auth/auth.controller.ts
index 6d46eedbf..3de52a9de 100644
--- a/backend/apps/community/src/auth/auth.controller.ts
+++ b/backend/apps/community/src/auth/auth.controller.ts
@@ -56,7 +56,7 @@ export class AuthController {
await checkRateLimit(ip, 'login', 10, 1800)
- const user = await this.authService.validateUser(body.email, body.password)
+ const user = await this.authService.getBasicUser(body.email, body.password)
if (!user) {
throw new ConflictException(i18n.t('auth.invalidCredentials'))
diff --git a/backend/apps/community/src/auth/auth.service.ts b/backend/apps/community/src/auth/auth.service.ts
index 8bb1f0c7d..b0842aa7e 100644
--- a/backend/apps/community/src/auth/auth.service.ts
+++ b/backend/apps/community/src/auth/auth.service.ts
@@ -48,7 +48,7 @@ export class AuthService {
)
}
- public async validateUser(
+ async getBasicUser(
email: string,
password: string,
): Promise<SelfhostedUser | null> {
diff --git a/backend/apps/community/src/project/project.controller.ts b/backend/apps/community/src/project/project.controller.ts
index 89862cf83..aaf297378 100644
--- a/backend/apps/community/src/project/project.controller.ts
+++ b/backend/apps/community/src/project/project.controller.ts
@@ -148,13 +148,16 @@ export class ProjectController {
{},
)
- const results = _map(formatted, p => ({
- ..._omit(p, ['passwordHash']),
- funnels: funnelsMap[p.id],
- isOwner: true,
+ const results = _map(formatted, project => ({
+ ..._omit(project, ['passwordHash']),
+ funnels: funnelsMap[project.id],
+ isDataExists: _includes(pidsWithData, project?.id),
+ isErrorDataExists: _includes(pidsWithErrorData, project?.id),
+
+ // these ones are not used, but we need to keep them for compatibility with the Cloud version
+ role: userId ? 'owner' : 'viewer',
isLocked: false,
- isDataExists: _includes(pidsWithData, p?.id),
- isErrorDataExists: _includes(pidsWithErrorData, p?.id),
+ isAccessConfirmed: true,
}))
return {
@@ -537,7 +540,7 @@ export class ProjectController {
@ApiResponse({ status: 200, type: Project })
async getOne(
@Param('id') id: string,
- @CurrentUserId() uid: string,
+ @CurrentUserId() userId: string,
@Headers() headers: { 'x-password'?: string },
): Promise<Project | object> {
this.logger.log({ id }, 'GET /project/:id')
@@ -553,14 +556,27 @@ export class ProjectController {
throw new NotFoundException('Project was not found in the database')
}
- if (project.isPasswordProtected && _isEmpty(headers['x-password'])) {
+ let allowedToViewNoPassword = false
+
+ try {
+ this.projectService.allowedToView(project, userId)
+ allowedToViewNoPassword = true
+ } catch {
+ allowedToViewNoPassword = false
+ }
+
+ if (
+ !allowedToViewNoPassword &&
+ project.isPasswordProtected &&
+ _isEmpty(headers['x-password'])
+ ) {
return {
isPasswordProtected: true,
id: project.id,
}
}
- this.projectService.allowedToView(project, uid, headers['x-password'])
+ this.projectService.allowedToView(project, userId, headers['x-password'])
const isDataExists = !_isEmpty(
await this.projectService.getPIDsWhereAnalyticsDataExists([id]),
@@ -577,6 +593,11 @@ export class ProjectController {
funnels: this.projectService.formatFunnelsFromClickhouse(funnels),
isDataExists,
isErrorDataExists,
+
+ // these ones are not used, but we need to keep them for compatibility with the Cloud version
+ role: userId ? 'owner' : 'viewer',
+ isLocked: false,
+ isAccessConfirmed: true,
})
}
diff --git a/backend/apps/community/src/user/user.controller.ts b/backend/apps/community/src/user/user.controller.ts
index 0a9d4a8c2..684f06ff7 100644
--- a/backend/apps/community/src/user/user.controller.ts
+++ b/backend/apps/community/src/user/user.controller.ts
@@ -34,10 +34,14 @@ export class UserController {
@Get('/me')
@UseGuards(RolesGuard)
@Roles(UserType.CUSTOMER, UserType.ADMIN)
- async me(@CurrentUserId() user_id: string): Promise<SelfhostedUser> {
+ async me(
+ @CurrentUserId() user_id: string,
+ ): Promise<{ user: SelfhostedUser }> {
this.logger.log({ user_id }, 'GET /user/me')
- return getSelfhostedUser()
+ return {
+ user: await getSelfhostedUser(),
+ }
}
@ApiBearerAuth()