Skip to content

Commit

Permalink
feat: add expiresIn to login response
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyoptimist committed Jun 14, 2024
1 parent 88c7db9 commit f00dde4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/domain/auth/dto.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package auth

type LoginResponse struct {
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
ExpiresIn float64 `json:"expiresIn"`
}

type LoginDto struct {
Expand Down
3 changes: 3 additions & 0 deletions internal/infrastructure/controller/auth_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"

"gin-starter/internal/config"
"gin-starter/internal/domain/auth"
"gin-starter/internal/infrastructure/helper"
"gin-starter/internal/infrastructure/repository"
Expand Down Expand Up @@ -44,6 +45,7 @@ func (a *authController) Register(c *gin.Context) {
utils.RaiseHttpError(c, http.StatusBadRequest, err)
return
}
loginResponse.ExpiresIn = config.Global.JwtAccessTokenExpiresIn.Seconds()

c.JSON(http.StatusCreated, loginResponse)
}
Expand All @@ -69,6 +71,7 @@ func (a *authController) Login(c *gin.Context) {
utils.RaiseHttpError(c, http.StatusUnauthorized, err)
return
}
loginResponse.ExpiresIn = config.Global.JwtAccessTokenExpiresIn.Seconds()

c.JSON(http.StatusCreated, loginResponse)
}
Expand Down

0 comments on commit f00dde4

Please sign in to comment.