chore: moved auth utility functions to auth/helper.ts from src/utils.ts

This commit is contained in:
Balu Babu
2023-02-01 18:47:11 +05:30
parent 587e7118c9
commit b5e7877912
4 changed files with 311 additions and 308 deletions

View File

@@ -11,15 +11,15 @@ import {
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { SignInMagicDto } from './dto/signin-magic.dto';
import { verifyMagicDto } from './dto/verify-magic.dto';
import { VerifyMagicDto } from './dto/verify-magic.dto';
import { Response } from 'express';
import * as E from 'fp-ts/Either';
import { authCookieHandler, throwHTTPErr } from 'src/utils';
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';
import { authCookieHandler, throwHTTPErr } from './helper';
@Controller('/v1/auth')
export class AuthController {
@@ -41,7 +41,7 @@ export class AuthController {
** Route to verify and sign in a valid user via magic-link
*/
@Post('verify')
async verify(@Body() data: verifyMagicDto, @Res() res: Response) {
async verify(@Body() data: VerifyMagicDto, @Res() res: Response) {
const authTokens = await this.authService.verifyMagicLinkTokens(data);
if (E.isLeft(authTokens)) throwHTTPErr(authTokens.left);
authCookieHandler(res, authTokens.right, false);