diff --git a/.env.development b/.env.development index 09d9bdf..3114ae8 100644 --- a/.env.development +++ b/.env.development @@ -3,5 +3,5 @@ MONGODB_URI=mongodb://0.0.0.0:27017/test SERVER_URL=http://localhost:3000/ PORT=4000 JWT_KEY='MXvTnOhWYMYgYiFnBFRfX4Fnd4ZkXLK8qYU' -IS_COOKIE_AUTH=true +IS_COOKIE_AUTH=false IS_EMAIL=false diff --git a/README.md b/README.md index a633190..c31c0cb 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![Prettier](https://img.shields.io/badge/Code%20style-prettier-informational?logo=prettier&logoColor=white) [![GPL v3 License](https://img.shields.io/badge/License-GPLv3-green.svg)](./LICENSE) -[![HitCount](https://hits.dwyl.com/anilahir/nestjs-authentication-and-authorization.svg)](https://hits.dwyl.com/vinodnextcoder/nestjs-jwt-auth-cookie-mongoose) +[![HitCount](https://hits.dwyl.com/vinodnextcoder/nestjs-jwt-auth-cookie-mongoose.svg)](https://hits.dwyl.com/vinodnextcoder/nestjs-jwt-auth-cookie-mongoose) ## Description diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 762b46e..6c01f35 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -61,6 +61,8 @@ export class AuthController { signInDto.password ); console.log(token) + console.log(signInDto.email, + signInDto.password) res.cookie("access_token", token.access_token, { httpOnly: true, diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 879b122..ca4e364 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -20,17 +20,21 @@ export class AuthService { const id: string = uuid(); this.logger.log('auth service api called', id, 'auth.service.ts', '', '', 'signIn-service'); const user = await this.usersService.findOneUser(email); + console.log(user) if (!user) { throw new UnauthorizedException('Username and password wrong.'); } const match = await bcrypt.compare(pass, user?.password); + console.log(match) if (match) { const payload = { email: user.email, userId: user._id.toString(), username: user.username }; const tokens = await this.getTokens(payload); return { ...tokens }; + } else { + throw new UnauthorizedException('Username and password wrong.'); } } diff --git a/src/users/users.controller.ts b/src/users/users.controller.ts index 806b61f..b668b97 100644 --- a/src/users/users.controller.ts +++ b/src/users/users.controller.ts @@ -109,6 +109,7 @@ export class UserController { @UseFilters(new HttpExceptionFilter()) async findUser(@Query('userid') name: string, @Req() req: UserRequest, @Res() res: Response): Promise { const id: string = uuid(); + console.log('=============================================================IN FUNCTION') this.logger.log('find User api called', id, 'users.controler.ts', 'GET', '/getuser', 'findUser'); let userid: string = null;