mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-11 15:49:08 +00:00
hubspot guard
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Req,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { InputsService } from './inputs.service';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
@@ -21,6 +23,7 @@ import {
|
||||
TestConnectionReq,
|
||||
TestConnectionRes,
|
||||
} from './dtos/input.model';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
|
||||
@ApiTags('inputs')
|
||||
@Controller('inputs')
|
||||
@@ -125,4 +128,14 @@ export class InputsController {
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('hubspot'))
|
||||
@Get('oauth/hubspot')
|
||||
async oauthHubspot(@Req() req) {
|
||||
return true;
|
||||
}
|
||||
@Get('oauth/hubspot/callback')
|
||||
async oauthHubspotCallback(@Req() req) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { Strategy } from 'passport-hubspot';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class HubspotStrategy extends PassportStrategy(Strategy) {
|
||||
constructor(private authService: AuthService) {
|
||||
super();
|
||||
constructor() {
|
||||
super({
|
||||
clientID: 'asd',
|
||||
clientSecret: '',
|
||||
callbackURL: 'http://localhost:4200/coletix/auth-callback',
|
||||
});
|
||||
}
|
||||
|
||||
async validate(username: string, password: string): Promise<any> {
|
||||
const user = await this.authService.validateUser(username, password);
|
||||
if (!user) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
return user;
|
||||
async validate(accessToken: string, refreshToken: string) {
|
||||
return { accessToken, refreshToken };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user