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!

added mock 'join project' by email link

Blue Mouse8d9caf334537
diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts
index 004f5a72c..1c31577de 100644
--- a/src/project/project.controller.ts
+++ b/src/project/project.controller.ts
@@ -563,8 +563,9 @@ export class ProjectController {
await this.userService.create(invitee)
// TODO: Implement link expiration
- const actionToken = await this.actionTokensService.createForUser(user, ActionTokenType.PROJECT_SHARE)
- const url = `${headers.origin}/verify/${actionToken.id}`
+ const actionToken = await this.actionTokensService.createForUser(user, ActionTokenType.PROJECT_SHARE, share.id)
+ // const url = `${headers.origin}/share/${actionToken.id}`
+ const url = `http://localhost:5005/project/share/${actionToken.id}`
await this.mailerService.sendEmail(invitee.email, LetterTemplate.ProjectInvitation, {
url, email: user.email, name: project.name, role: share.role, expiration: PROJECT_INVITE_EXPIRE,
})
@@ -577,4 +578,31 @@ export class ProjectController {
throw new BadRequestException(e)
}
}
+
+ @HttpCode(204)
+ @UseGuards(SelfhostedGuard)
+ // @UseGuards(RolesGuard)
+ // @Roles(UserType.CUSTOMER, UserType.ADMIN)
+ @ApiResponse({ status: 204, description: 'Empty body' })
+ @Get('/share/:id')
+ async acceptShare(@Param('id') id: string): Promise<any> {
+ this.logger.log({ id }, 'GET /project/share/:id')
+ let actionToken
+
+ try {
+ actionToken = await this.actionTokensService.find(id)
+ } catch {
+ throw new BadRequestException('Incorrect token provided')
+ }
+
+ console.log(actionToken, actionToken.action, ActionTokenType.PROJECT_SHARE)
+
+ // TODO
+
+ if (actionToken.action === ActionTokenType.PROJECT_SHARE) {
+ // await this.userService.update(actionToken.user.id, { ...actionToken.user, isActive: true})
+ // await this.actionTokensService.delete(actionToken.id)
+ // return
+ }
+ }
}