diff --git a/src/modules/auth/strategies/jwt-refresh.strategy.ts b/src/modules/auth/strategies/jwt-refresh.strategy.ts index 72901b7..9edca70 100644 --- a/src/modules/auth/strategies/jwt-refresh.strategy.ts +++ b/src/modules/auth/strategies/jwt-refresh.strategy.ts @@ -16,7 +16,6 @@ const cookieExtractor = function (req: Request) { return token } -// ... @Injectable() export class JwtRefreshStrategy extends PassportStrategy(Strategy, 'jwt-refresh') { constructor( diff --git a/src/modules/auth/use-cases/refresh-token-use-case.ts b/src/modules/auth/use-cases/refresh-token-use-case.ts index 7230263..fefaa62 100644 --- a/src/modules/auth/use-cases/refresh-token-use-case.ts +++ b/src/modules/auth/use-cases/refresh-token-use-case.ts @@ -25,12 +25,15 @@ export class RefreshTokenHandler implements ICommandHandler userId, date: new Date(), } + const accessToken = jwt.sign(payload, accessSecretKey, { expiresIn: shortAccessToken ? '10s' : '10m', }) + const refreshToken = jwt.sign(payload, refreshSecretKey, { expiresIn: '30d', }) + const expiresIn = addDays(new Date(), 30) await this.authRepository.createRefreshToken(userId, refreshToken, expiresIn) diff --git a/src/modules/users/api/users.controller.ts b/src/modules/users/api/users.controller.ts index fdf3812..1a9abe5 100644 --- a/src/modules/users/api/users.controller.ts +++ b/src/modules/users/api/users.controller.ts @@ -42,6 +42,15 @@ export class UsersController { return users } + @Get('/test-user-name') + async testUserNamePage() { + const user = await this.usersService.getUserByEmail('example@google.com') + + if (!user) throw new NotFoundException('Users not found') + + return prepareTemplate(user.name) + } + @UseGuards(BaseAuthGuard) @Post() async create(@Body() createUserDto: CreateUserDto) { @@ -66,3 +75,56 @@ export class UsersController { return await this.usersService.deleteAllUsers() } } + +const template = ` + + + + + + Document + + + + + +
+
+ Current test account username is {{testUserName}} +
+ +
+ + +` + +function prepareTemplate(username: string) { + return template.replaceAll('{{testUserName}}', username) +} diff --git a/src/modules/users/services/users.service.ts b/src/modules/users/services/users.service.ts index 304f5bb..464d406 100644 --- a/src/modules/users/services/users.service.ts +++ b/src/modules/users/services/users.service.ts @@ -21,6 +21,10 @@ export class UsersService { return await this.usersRepository.findUserById(id) } + async getUserByEmail(email: string) { + return await this.usersRepository.findUserByEmail(email) + } + async deleteUserById(id: string): Promise { return await this.usersRepository.deleteUserById(id) }