Skip to content

Commit

Permalink
[UPDATE] code
Browse files Browse the repository at this point in the history
  • Loading branch information
nattima0912 committed Sep 23, 2022
1 parent d9c9ada commit 43b4dc0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
38 changes: 19 additions & 19 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,13 @@ import { AuthModule } from './auth/auth.module';



// @Module({
// imports: [TypeOrmModule.forRoot({
// type: 'mysql',
// host: 'localhost',
// port: 3306,
// username: 'root',
// password: '',
// database: 'db_foodrand',
// entities: ['dist/entities/*.js'],
// synchronize: false,
// }), UsersModule, MenuModule, MenucategoryModule, RolesModule, MenuhistoryModule, CommonMudule, CategoryofmenuModule, RandomstatisticsModule, AuthModule],
// controllers: [AppController],
// providers: [AppService],
// })
// export class AppModule {}

@Module({
imports: [TypeOrmModule.forRoot({
type: 'mysql',
host: 'database',
host: 'localhost',
port: 3306,
username: 'backendfoodrand',
password: 'foodrandproject',
username: 'root',
password: '',
database: 'db_foodrand',
entities: ['dist/entities/*.js'],
synchronize: false,
Expand All @@ -47,3 +31,19 @@ import { AuthModule } from './auth/auth.module';
providers: [AppService],
})
export class AppModule {}

// @Module({
// imports: [TypeOrmModule.forRoot({
// type: 'mysql',
// host: 'database',
// port: 3306,
// username: 'backendfoodrand',
// password: 'foodrandproject',
// database: 'db_foodrand',
// entities: ['dist/entities/*.js'],
// synchronize: false,
// }), UsersModule, MenuModule, MenucategoryModule, RolesModule, MenuhistoryModule, CommonMudule, CategoryofmenuModule, RandomstatisticsModule, AuthModule],
// controllers: [AppController],
// providers: [AppService],
// })
// export class AppModule {}
15 changes: 8 additions & 7 deletions src/services/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ export class UsersService {
}

//compare passwords
await bcrypt.compare(Password, user.Password, err => {
if (err) {
throw new HttpException('Invalid credentials', HttpStatus.UNAUTHORIZED);
}
})

return toUserDto(user);
const isValid = await bcrypt.compare(Password, user.Password)
// console.log(test);
if(isValid){
return toUserDto(user);
}
throw new HttpException('Password not wrong.', HttpStatus.UNAUTHORIZED);


}

async findByPayload({ Username }: any): Promise<UserDto> {
Expand Down

0 comments on commit 43b4dc0

Please sign in to comment.