return access and refresh tokens
This commit is contained in:
parent
c18ab4576e
commit
96e6523d46
1 changed files with 13 additions and 3 deletions
|
|
@ -167,7 +167,7 @@ func (co *controller) delete(c *gin.Context) {
|
|||
// @Tags Users - auth
|
||||
// @Accept json
|
||||
// @Param body body Login true "логин"
|
||||
// @Success 200 {object} LoginResponse
|
||||
// @Success 200 {object} LoginResponse
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Router /user/login [post]
|
||||
|
|
@ -229,7 +229,7 @@ func (co *controller) logout(c *gin.Context) {
|
|||
// @Description Принимает рефреш токен в заголовке Authorization
|
||||
// @Tags Users - auth
|
||||
// @Security BearerAuth
|
||||
// @Success 200
|
||||
// @Success 200 {object} LoginResponse
|
||||
// @Failure 400 {object} responses.ErrorResponse400s
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Router /user/refresh [post]
|
||||
|
|
@ -249,5 +249,15 @@ func (co *controller) refresh(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
c.SetCookie(
|
||||
response.RefreshCookie.Name,
|
||||
response.RefreshCookie.Value,
|
||||
int(time.Until(response.RefreshCookie.Expires).Seconds()),
|
||||
co.authPath,
|
||||
"",
|
||||
response.RefreshCookie.Secure,
|
||||
response.RefreshCookie.HttpOnly,
|
||||
)
|
||||
|
||||
c.JSON(http.StatusOK, LoginResponse{AccessToken: response.AccessToken})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue