fix user
This commit is contained in:
parent
2b5abc7689
commit
74711e0823
|
@ -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 {}
|
||||
|
|
|
@ -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<UserDto> {
|
||||
const user = await this.authService.validateUser(payload);
|
||||
if (!user) {
|
||||
throw new HttpException('Invalid token', HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
// async validate(payload: JwtPayload): Promise<UserDto> {
|
||||
// const user = await this.authService.validateUser(payload);
|
||||
// if (!user) {
|
||||
// throw new HttpException('Invalid token', HttpStatus.UNAUTHORIZED);
|
||||
// }
|
||||
// return user;
|
||||
// }
|
||||
// }
|
|
@ -2,8 +2,8 @@ import { IsNotEmpty } from 'class-validator';
|
|||
|
||||
export class CreateUserDto {
|
||||
@IsNotEmpty()
|
||||
firstName: string;
|
||||
username: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
lastName: string;
|
||||
password: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user