Skip to content

Commit

Permalink
feat: update reset password ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitiwat-owen committed Jan 14, 2024
1 parent 7f31f0e commit a792f6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/service/token/token.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (s *serviceImpl) CreateResetPasswordToken(userId string) (string, error) {
tokenCache := &tokenDto.ResetPasswordTokenCache{
UserID: userId,
}
err := s.resetPasswordTokenCache.SetValue(resetPasswordToken, tokenCache, 900)
err := s.resetPasswordTokenCache.SetValue(resetPasswordToken, tokenCache, s.jwtService.GetConfig().ResetTokenTTL)
if err != nil {
return "", err
}
Expand Down
7 changes: 5 additions & 2 deletions internal/service/token/token.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (t *TokenServiceTest) SetupTest() {
ExpiresIn: 3600,
RefreshTokenTTL: 604800,
Issuer: "testIssuer",
ResetTokenTTL: 900,
}
validateToken := ""

Expand Down Expand Up @@ -592,7 +593,8 @@ func (t *TokenServiceTest) TestCreateResetPasswordTokenSuccess() {
uuidUtil := utils.UuidUtilMock{}

uuidUtil.On("GetNewUUID").Return(t.refreshToken)
resetPasswordTokenRepo.EXPECT().SetValue(t.refreshToken.String(), tokenCache, 900).Return(nil)
jwtService.On("GetConfig").Return(t.jwtConfig)
resetPasswordTokenRepo.EXPECT().SetValue(t.refreshToken.String(), tokenCache, t.jwtConfig.ResetTokenTTL).Return(nil)

tokenSvc := NewService(&jwtService, accessTokenRepo, refreshTokenRepo, resetPasswordTokenRepo, &uuidUtil)
actual, err := tokenSvc.CreateResetPasswordToken(t.userId)
Expand All @@ -618,7 +620,8 @@ func (t *TokenServiceTest) TestCreateResetPasswordTokenFailed() {
uuidUtil := utils.UuidUtilMock{}

uuidUtil.On("GetNewUUID").Return(t.refreshToken)
resetPasswordTokenRepo.EXPECT().SetValue(t.refreshToken.String(), tokenCache, 900).Return(cacheErr)
jwtService.On("GetConfig").Return(t.jwtConfig)
resetPasswordTokenRepo.EXPECT().SetValue(t.refreshToken.String(), tokenCache, t.jwtConfig.ResetTokenTTL).Return(cacheErr)

tokenSvc := NewService(&jwtService, accessTokenRepo, refreshTokenRepo, resetPasswordTokenRepo, &uuidUtil)
actual, err := tokenSvc.CreateResetPasswordToken(t.userId)
Expand Down

0 comments on commit a792f6f

Please sign in to comment.