fix: check profiles and orgId from user.profiles apiv2 (#16249)
* fix: check profiles and orgId from user.profiles apiv2 * fixup! fix: check profiles and orgId from user.profiles apiv2 --------- Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
This commit is contained in:
co-authored by
Lauris Skraucis
parent
7759e6a029
commit
1690770d6a
@@ -1,5 +1,6 @@
|
||||
import { GetUserReturnType } from "@/modules/auth/decorators/get-user/get-user.decorator";
|
||||
import { OAuthClientRepository } from "@/modules/oauth-clients/oauth-client.repository";
|
||||
import { UsersService } from "@/modules/users/services/users.service";
|
||||
import { WebhooksService } from "@/modules/webhooks/services/webhooks.service";
|
||||
import {
|
||||
CanActivate,
|
||||
@@ -17,7 +18,8 @@ import { PlatformOAuthClient, Webhook } from "@calcom/prisma/client";
|
||||
export class IsOAuthClientWebhookGuard implements CanActivate {
|
||||
constructor(
|
||||
private readonly webhooksService: WebhooksService,
|
||||
private readonly oAuthClientRepository: OAuthClientRepository
|
||||
private readonly oAuthClientRepository: OAuthClientRepository,
|
||||
private usersService: UsersService
|
||||
) {}
|
||||
|
||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
@@ -27,7 +29,7 @@ export class IsOAuthClientWebhookGuard implements CanActivate {
|
||||
const user = request.user as GetUserReturnType;
|
||||
const webhookId = request.params.webhookId;
|
||||
const oAuthClientId = request.params.clientId;
|
||||
const organizationId = user.movedToProfile?.organizationId || user.organizationId;
|
||||
const organizationId = this.usersService.getUserMainOrgId(user);
|
||||
|
||||
if (!user) {
|
||||
throw new ForbiddenException("User not authenticated");
|
||||
|
||||
Reference in New Issue
Block a user