From 74711e08233f8473345a33da3a1e7eeb0a62ef23 Mon Sep 17 00:00:00 2001 From: Ilham Dwi Pratama S Date: Mon, 6 Dec 2021 05:07:07 +0700 Subject: [PATCH] fix user --- src/app.module.ts | 8 +++---- src/helper/jwt.strategy.ts | 40 ++++++++++++++++---------------- src/users/dto/create-user.dto.ts | 4 ++-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/app.module.ts b/src/app.module.ts index 3bc5761..23cd81c 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -8,7 +8,7 @@ import { LoggerModule } from 'nestjs-pino'; import { TransactionModule } from './transaction/transaction.module'; import { ProductModule } from './product/product.module'; import { ConfigurableModule } from './configurable/configurable.module'; -import { AuthModule } from './auth/auth.module'; +// import { AuthModule } from './auth/auth.module'; import configuration from './config/configuration'; @Module({ @@ -48,11 +48,11 @@ import configuration from './config/configuration'; }, inject: [ConfigService], }), - UsersModule, + // UsersModule, TransactionModule, ConfigurableModule, - AuthModule, - // ProductModule, + // AuthModule, + ProductModule, ], }) export class AppModule {} diff --git a/src/helper/jwt.strategy.ts b/src/helper/jwt.strategy.ts index c5d278e..2ec61b2 100644 --- a/src/helper/jwt.strategy.ts +++ b/src/helper/jwt.strategy.ts @@ -1,22 +1,22 @@ -import { PassportStrategy } from '@nestjs/passport'; -import { ExtractJwt, Strategy } from 'passport-jwt'; -import { Injectable } from '@nestjs/common'; -import { AuthService } from '../auth/auth.service'; +// import { PassportStrategy } from '@nestjs/passport'; +// import { ExtractJwt, Strategy } from 'passport-jwt'; +// import { Injectable } from '@nestjs/common'; +// import { AuthService } from '../auth/auth.service'; -@Injectable() -export class JwtStrategy extends PassportStrategy(Strategy) { - constructor(private readonly authService: AuthService) { - super({ - jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), - secretOrKey: process.env.SECRETKEY, - }); - } +// @Injectable() +// export class JwtStrategy extends PassportStrategy(Strategy) { +// constructor(private readonly authService: AuthService) { +// super({ +// jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), +// secretOrKey: process.env.SECRETKEY, +// }); +// } - async validate(payload: JwtPayload): Promise { - const user = await this.authService.validateUser(payload); - if (!user) { - throw new HttpException('Invalid token', HttpStatus.UNAUTHORIZED); - } - return user; - } -} \ No newline at end of file +// async validate(payload: JwtPayload): Promise { +// const user = await this.authService.validateUser(payload); +// if (!user) { +// throw new HttpException('Invalid token', HttpStatus.UNAUTHORIZED); +// } +// return user; +// } +// } \ No newline at end of file diff --git a/src/users/dto/create-user.dto.ts b/src/users/dto/create-user.dto.ts index 8b676ac..f6c8301 100644 --- a/src/users/dto/create-user.dto.ts +++ b/src/users/dto/create-user.dto.ts @@ -2,8 +2,8 @@ import { IsNotEmpty } from 'class-validator'; export class CreateUserDto { @IsNotEmpty() - firstName: string; + username: string; @IsNotEmpty() - lastName: string; + password: string; }