Skip to content

Commit

Permalink
[calendar] change api scope (#4888)
Browse files Browse the repository at this point in the history
## Context
Calendar scope was too broad, this PR updates it to events only.
Also changing "Cannot connect Google account to demo workspace" error to
a 404 to avoid having a 500 for something expected
  • Loading branch information
Weiko authored Apr 9, 2024
1 parent 35717fc commit 19df431
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Controller, Get, Req, Res, UseGuards } from '@nestjs/common';
import {
Controller,
Get,
Req,
Res,
UnauthorizedException,
UseGuards,
} from '@nestjs/common';

import { Response } from 'express';

Expand Down Expand Up @@ -40,7 +47,9 @@ export class GoogleAPIsAuthController {
const demoWorkspaceIds = this.environmentService.get('DEMO_WORKSPACE_IDS');

if (demoWorkspaceIds.includes(workspaceId)) {
throw new Error('Cannot connect Google account to demo workspace');
throw new UnauthorizedException(
'Cannot connect Google account to demo workspace',
);
}

if (!workspaceId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class GoogleAPIsStrategy extends PassportStrategy(
}

if (environmentService.get('CALENDAR_PROVIDER_GOOGLE_ENABLED')) {
scope.push('https://www.googleapis.com/auth/calendar');
scope.push('https://www.googleapis.com/auth/calendar.events');
}

super({
Expand Down

0 comments on commit 19df431

Please sign in to comment.