[calendar] change api scope (#4888)
## 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
This commit is contained in:
@ -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';
|
import { Response } from 'express';
|
||||||
|
|
||||||
@ -40,7 +47,9 @@ export class GoogleAPIsAuthController {
|
|||||||
const demoWorkspaceIds = this.environmentService.get('DEMO_WORKSPACE_IDS');
|
const demoWorkspaceIds = this.environmentService.get('DEMO_WORKSPACE_IDS');
|
||||||
|
|
||||||
if (demoWorkspaceIds.includes(workspaceId)) {
|
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) {
|
if (!workspaceId) {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ export class GoogleAPIsStrategy extends PassportStrategy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (environmentService.get('CALENDAR_PROVIDER_GOOGLE_ENABLED')) {
|
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({
|
super({
|
||||||
|
|||||||
Reference in New Issue
Block a user