chore: cleaned unwanted imports in auth module

This commit is contained in:
Balu Babu
2023-01-20 00:04:01 +05:30
parent 53571a7d72
commit 509604833e
5 changed files with 6345 additions and 5 deletions

6335
packages/hoppscotch-backend/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
#!/bin/bash
cd /home/balubabu/work/self-hosted/packages/hoppscotch-backend

View File

@@ -63,6 +63,8 @@ export class AuthController {
async googleAuthRedirect(@Request() req, @Res() res) { async googleAuthRedirect(@Request() req, @Res() res) {
const authTokens = await this.authService.generateAuthTokens(req.user.uid); const authTokens = await this.authService.generateAuthTokens(req.user.uid);
if (E.isLeft(authTokens)) throwHTTPErr(authTokens.left); if (E.isLeft(authTokens)) throwHTTPErr(authTokens.left);
console.log('google', authTokens);
authCookieHandler(res, authTokens.right, true); authCookieHandler(res, authTokens.right, true);
} }

View File

@@ -5,7 +5,7 @@ import { UserModule } from 'src/user/user.module';
import { MailerModule } from 'src/mailer/mailer.module'; import { MailerModule } from 'src/mailer/mailer.module';
import { PrismaModule } from 'src/prisma/prisma.module'; import { PrismaModule } from 'src/prisma/prisma.module';
import { PassportModule } from '@nestjs/passport'; import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt/dist'; import { JwtModule } from '@nestjs/jwt';
import { JwtStrategy } from './strategies/jwt.strategy'; import { JwtStrategy } from './strategies/jwt.strategy';
import { RTJwtStrategy } from './strategies/rt-jwt.strategy'; import { RTJwtStrategy } from './strategies/rt-jwt.strategy';
import { GoogleStrategy } from './strategies/google.strategy'; import { GoogleStrategy } from './strategies/google.strategy';

View File

@@ -18,13 +18,12 @@ import {
@Injectable() @Injectable()
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') { export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
constructor( constructor(private usersService: UserService) {
private usersService: UserService,
private authService: AuthService,
) {
super({ super({
jwtFromRequest: ExtractJwt.fromExtractors([ jwtFromRequest: ExtractJwt.fromExtractors([
(request: Request) => { (request: Request) => {
console.log('here1', request.cookies);
const ATCookie = request.cookies['access_token']; const ATCookie = request.cookies['access_token'];
if (!ATCookie) { if (!ATCookie) {
throw new ForbiddenException(COOKIES_NOT_FOUND); throw new ForbiddenException(COOKIES_NOT_FOUND);
@@ -38,6 +37,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
async validate(payload: AccessTokenPayload) { async validate(payload: AccessTokenPayload) {
if (!payload) throw new ForbiddenException(INVALID_ACCESS_TOKEN); if (!payload) throw new ForbiddenException(INVALID_ACCESS_TOKEN);
console.log('here', payload);
const user = await this.usersService.findUserById(payload.sub); const user = await this.usersService.findUserById(payload.sub);
if (O.isNone(user)) { if (O.isNone(user)) {