feat: google sso auth added

This commit is contained in:
Balu Babu
2023-01-13 00:52:29 +05:30
parent 6f4c5d7195
commit f4df8873be
8 changed files with 181 additions and 54 deletions

View File

@@ -19,6 +19,7 @@ import { RTJwtAuthGuard } from './guards/rt-jwt-auth.guard';
import { GqlUser } from 'src/decorators/gql-user.decorator';
import { AuthUser } from 'src/types/AuthUser';
import { RTCookie } from 'src/decorators/rt-cookie.decorator';
import { AuthGuard } from '@nestjs/passport';
@Controller('auth')
export class AuthController {
@@ -52,4 +53,16 @@ export class AuthController {
if (E.isLeft(newTokenPair)) throwHTTPErr(newTokenPair.left);
authCookieHandler(res, newTokenPair.right, false);
}
@Get('google')
@UseGuards(AuthGuard('google'))
async googleAuth(@Request() req) {}
@Get('google/callback')
@UseGuards(AuthGuard('google'))
async googleAuthRedirect(@Request() req, @Res() res) {
const authTokens = await this.authService.generateAuthTokens(req.user.id);
if (E.isLeft(authTokens)) throwHTTPErr(authTokens.left);
authCookieHandler(res, authTokens.right, true);
}
}