📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
return shared projects data for user login
Blue Mouse08805e7e5644
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.tsindex e724d7c8e..b5efd6ec2 100644--- a/src/auth/auth.controller.ts+++ b/src/auth/auth.controller.ts@@ -12,6 +12,7 @@ import { MailerService } from '../mailer/mailer.service'import { ActionTokensService } from '../action-tokens/action-tokens.service'import { ActionTokenType } from '../action-tokens/action-token.entity'import { User, UserType } from '../user/entities/user.entity'+import { ProjectService } from 'src/project/project.service'import { PasswordChangeDTO } from './dto/password-change.dto'import { RequestPasswordChangeDTO } from './dto/request-pass-change.dto'import { RolesGuard } from '../common/guards/roles.guard'@@ -35,6 +36,7 @@ export class AuthController {private userService: UserService,private mailerService: MailerService,private actionTokensService: ActionTokensService,+ private readonly projectService: ProjectService,private readonly logger: AppLoggerService) {}@@ -51,9 +53,17 @@ export class AuthController {email: SELFHOSTED_EMAIL,}} else {+ const sharedProjects = await this.projectService.findShare({+ where: {+ user: user_id,+ },+ relations: ['project'],+ })user = this.authService.processUser(- await this.userService.findOneWhere({ id: user_id }, ['sharedProjects'])+ await this.userService.findOneWhere({ id: user_id }))++ user.sharedProjects = sharedProjects}return this.userService.omitSensitiveData(user)@@ -75,6 +85,15 @@ export class AuthController {})} else {const user = await this.authService.validateUser(userLoginDTO.email, userLoginDTO.password)+ const sharedProjects = await this.projectService.findShare({+ where: {+ user: user.id,+ },+ relations: ['project'],+ })++ user.sharedProjects = sharedProjects+return this.authService.login(user)}}@@ -110,6 +129,7 @@ export class AuthController {const actionToken = await this.actionTokensService.createForUser(user, ActionTokenType.EMAIL_VERIFICATION)const url = `${request.headers.origin}/verify/${actionToken.id}`await this.mailerService.sendEmail(userDTO.email, LetterTemplate.SignUp, { url })+ user.sharedProjects = []return this.authService.login(user)} catch(e) {diff --git a/src/auth/auth.module.ts b/src/auth/auth.module.tsindex 6efa7013e..a17cc47c3 100644--- a/src/auth/auth.module.ts+++ b/src/auth/auth.module.ts@@ -3,6 +3,7 @@ import { AuthService } from './auth.service'import { UserModule } from '../user/user.module'import { AuthController } from './auth.controller'import { MailerModule } from '../mailer/mailer.module'+import { ProjectModule } from '../project/project.module'import { ActionTokensModule } from '../action-tokens/action-tokens.module'import { AppLoggerModule } from '../logger/logger.module'@@ -12,6 +13,7 @@ import { AppLoggerModule } from '../logger/logger.module'MailerModule,ActionTokensModule,AppLoggerModule,+ ProjectModule,],controllers: [AuthController],providers: [AuthService],diff --git a/src/user/user.controller.ts b/src/user/user.controller.tsindex fb0d95d42..e2d74800d 100644--- a/src/user/user.controller.ts+++ b/src/user/user.controller.ts@@ -174,7 +174,7 @@ export class UserController {@Param('shareId') shareId: string,@CurrentUserId() uid: string,): Promise<any> {- this.logger.log({ uid, shareId }, 'DELETE /share/:shareId')+ this.logger.log({ uid, shareId }, 'DELETE /user/share/:shareId')const share = await this.projectService.findShare({where: {@@ -201,7 +201,7 @@ export class UserController {@UseGuards(SelfhostedGuard)@Roles(UserType.CUSTOMER, UserType.ADMIN)async sendEmailConfirmation(@CurrentUserId() id: string, @Req() request: Request): Promise<boolean> {- this.logger.log({ id }, 'POST /confirm_email')+ this.logger.log({ id }, 'POST /user/confirm_email')const user = await this.userService.findOneWhere({ id })@@ -273,7 +273,8 @@ export class UserController {await this.mailerService.sendEmail(user.email, LetterTemplate.MailAddressChangeConfirmation, { url })}// delete internal properties from userDTO before updating it- const userToUpdate = _omit(userDTO, ['id', 'isActive', 'evWarningSentOn', 'exportedAt', 'subID', 'subUpdateURL', 'subCancelURL', 'projects', 'actionTokens', 'roles', 'created', 'updated', 'planCode'])+ // todo: use _pick instead of _omit+ const userToUpdate = _omit(userDTO, ['id', 'sharedProjects', 'isActive', 'evWarningSentOn', 'exportedAt', 'subID', 'subUpdateURL', 'subCancelURL', 'projects', 'actionTokens', 'roles', 'created', 'updated', 'planCode'])await this.userService.update(id, userToUpdate)const updatedUser = await this.userService.findOneWhere({ id })