-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from isdi-coders-2023/feature/claims
Fix guards logic
- Loading branch information
Showing
9 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { JwtService } from '@nestjs/jwt'; | |
import { ConfigService } from '@nestjs/config'; | ||
|
||
import { hash, compare } from 'bcrypt'; | ||
import { SignUser } from 'src/users/entities/user.entity'; | ||
import { LogUser } from '../../users/entities/user.entity'; | ||
jest.mock('bcrypt', () => ({ | ||
hash: jest.fn().mockResolvedValue('hashedValue'), | ||
compare: jest.fn().mockResolvedValue(true), | ||
|
@@ -59,10 +59,10 @@ describe('CryptoService', () => { | |
|
||
describe('When we call createToken method', () => { | ||
it('should return a token', async () => { | ||
const user: SignUser = { email: '[email protected]', password: '' }; | ||
const user: LogUser = { email: '[email protected]', id: '4' }; | ||
const result = await service.createToken(user); | ||
expect(jwtServiceMock.signAsync).toHaveBeenCalledWith( | ||
{ email: '[email protected]' }, | ||
{ email: '[email protected]', id: '4' }, | ||
{ secret: 'SECRET_JWT' }, | ||
); | ||
expect(result).toBe('token'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ export class UsersService { | |
select: { | ||
email: true, | ||
password: true, | ||
id: true, | ||
}, | ||
}); | ||
|
||
|